POST
|
Hi everyone, I'm trying to find intersection of two polylines with a set of polygons to determine the segment of each polyline that intersects with the polygons. below is my sample code, I want to get the length of the polyline's segments that intersecte with the polygons but I continuously get one of the following error messages: 1-Eceptions.TypeError:Invalid geometry type for method- : I get this error when I use (GEODESIC,PLANAR, GREAT_ELLIPTIC)as a type measurement in "getLength"method. 2- Access violation at address 5C5B11E8 in module 'GeometryXLib.dll'. Read of address 00000000: I get this error when I use (PRESERVE_SHAPE) as a type measurment in "getLength"method. I don't Know How to solve it. Any help and suggestion are greatly appreciated. The Code is : import arcpy path="E:\Code_Python\Data_trial.gdb" arcpy.env.workspace=path infc="CandidateStations_clipped" fc="PopulationDensity_poly_del" OBJ_field="OBJECTID" #-------------------------------------------------------------------------- def get_station_shape(station_id): with arcpy.da.SearchCursor(infc,"shape@",'%s = %s'%(OBJ_field,station_id)) as cursor: t1=cursor.next()[0].lastPoint return t1 #------------------------------------------------------------------------------ def get_population_shape(pop_stns): for i in range (len(pop_stns)): pop_list.append(get_station_shape(pop_stns)) return pop_list #----------------------------------------------------------------------------- def determine_line_length(pop_list_line): pop_line=arcpy.Polyline(arcpy.Array([get_population_shape(pop_list_line)])) return pop_line #------------------------------------------------------------------------ # Enter for loop for each feature def get_polygon_shape(fc): pd_poly=[] for row in arcpy.da.SearchCursor(fc, ["OBJECTID", "SHAPE@"]): # Print the current multipoint's ID print("Feature {0}:".format(row[0])) partnum = 0 # Step through each part of the feature for part in row[1]: # Print the part number print("Part {0}:".format(partnum)) # Step through each vertex in the feature for pnt in part: poly=[] if pnt: poly.append(pnt) # Print x,y coordinates of current point # print("{0}, {1}".format(pnt.X, pnt.Y)) else: # If pnt is None, this represents an interior ring # print("Interior Ring:") tmp_poly=arcpy.Polygon(arcpy.Array(poly)) pd_poly.append(tmp_poly) print tmp_poly partnum += 1 print pd_poly return(tmp_poly) #--------------------------------------------------------------------------- pop_list_line=[[2,9],[1,7]] for i in range(len(pop_list_line)): pop_list=[] pop_line=determine_line_length(pop_list_line) intersect=pop_line.intersect((get_polygon_shape(fc)),2) print intersect pop_list.append(intersect.getLength("GEODESIC")) print "pop_list=",pop_list
... View more
12-11-2014
05:37 AM
|
0
|
0
|
3015
|
POST
|
Dear Chris Many thanks for your suggestion. I will try it. Best regards,
... View more
12-11-2014
12:53 AM
|
0
|
0
|
421
|
POST
|
Dear Dan Thank you very much for your quick response and suggestion.The cutter method in the polyline class is only available form ArcGIS 10.2 and later versions , and I got ArcGIS 10.1. So, I wonder to know if there is any other possible alternative to try . Many thanks,
... View more
12-10-2014
06:06 AM
|
0
|
1
|
421
|
POST
|
Hi everyone, I have a simple railway line, linking two rail stations, which is defined by a polyline array and a polygon feature class representing land value. I need to be able to attribute each railway segment with the land value that it falls within. The tricky part is that the railway crosses different land value boundaries and I need to be able to split it at the boundary so each segment will only fall within one land value. Does anyone have accomplished problem like this using Python? Or is there any way to do it using geometry objects? Or might there be a different solution I'm missing? Any help and suggestions would be greatly appreciated. Many thanks,
... View more
12-10-2014
04:37 AM
|
0
|
6
|
2631
|
POST
|
I want to link a specified number of rail stations considering construction cost of the line that joins the stations. The factors that I want to consider for calculating the construction cost include land value and soil type, which I have them in separate feature classes. The problem is I don’t how to get land value and soil type of each piece of the line that connects two stations using arcpy. Any suggestion and help will be greatly appreciated. Best regards, Chro,
... View more
12-05-2014
10:55 AM
|
0
|
1
|
2043
|
POST
|
Dear Dan Thank you very much you are true,once I provided the extension "gdb" it worked. Many thanks once again
... View more
11-23-2014
10:49 AM
|
0
|
0
|
521
|
POST
|
Dear Dan Thank you very much for your response. I tried it, but again it showed the same warning message! Best regards,
... View more
11-11-2014
11:17 AM
|
0
|
0
|
521
|
POST
|
Same python code works in Arcgis python window, but fails in pyScripter. This code works in the arcgis python window but in PyScripter,it shows a warring message of: (Exceptions. IO Error: "CandidateStations_Centroid" does not exist)! import arcpy path=("C:/Users/fazeel/Desktop/ExampleCase/LeicesterCity_Leeds") arcpy.env.workspace=path fields=arcpy.ListFields("CandidateStations_Centroid") for fld in fields: print fld.name I wonder to know the reason of this warring message, any suggestion please? Many thanks
... View more
11-11-2014
10:36 AM
|
0
|
6
|
2342
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|