-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreatePairForLine_100m.py
More file actions
46 lines (40 loc) · 2.04 KB
/
CreatePairForLine_100m.py
File metadata and controls
46 lines (40 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#CreatePairForLine_1km
#Create pairs for 100m grid
import sys, arcpy
arcpy.env.overwriteOutput = 1 # enable overwriting
try:
# load the point featrure class
# arcpy.env.workspace = arcpy.GetParameterAsText(0)
# fc = "C:/Users/koitaroh/Docments/ArcGIS/Default.gdb/WeightPoint_Test"
fc = arcpy.GetParameterAsText(0)
outtable_path = arcpy.GetParameterAsText(1)
# fc = "F:/HumanTrafficking/HumanTrafficking_UTM_Sub.gdb/Fishnet_point_140114_1049"
# outtable_path =
# define variables
fields = ["POINT_X", "POINT_Y", "pointid"]
xcoord = 0.0
ycoord = 0.0
pointid = 0
# print("INITIALIZED")
# create a insert cursor
cursor2 = arcpy.da.InsertCursor(outtable_path, ("pointid", "origin_x", "origin_y", "destination_x", "destination_y"))
# create a search cursor
# insert pairs to table
with arcpy.da.SearchCursor(fc, fields) as cursor1:
for row in cursor1:
xcoord = row[0]
ycoord = row[1]
pointid = row[2]
cursor2.insertRow((rowid, xcoord+100, ycoord, xcoord, ycoord, height, landcover, slope))
cursor2.insertRow((rowid, xcoord, ycoord+100, xcoord, ycoord, height, landcover, slope))
cursor2.insertRow((rowid, xcoord-100, ycoord, xcoord, ycoord, height, landcover, slope))
cursor2.insertRow((rowid, xcoord, ycoord-100, xcoord, ycoord, height, landcover, slope))
cursor2.insertRow((rowid, xcoord+100, ycoord+100, xcoord, ycoord, height, landcover, slope))
cursor2.insertRow((rowid, xcoord+100, ycoord-100, xcoord, ycoord, height, landcover, slope))
cursor2.insertRow((rowid, xcoord-100, ycoord+100, xcoord, ycoord, height, landcover, slope))
cursor2.insertRow((rowid, xcoord-100, ycoord-100, xcoord, ycoord, height, landcover, slope))
#rows = arcpy.da.SearchCursor(fc, "POINT_X" between x+10 and x-10 AND "POINT_Y" between y+10 and y-10 )
del cursor1
del cursor2
except:
print arcpy.GetMessages(2)