POST
|
Ok, I thinked something similar … but I always thinked that all spatial information was inside the SHAPE field and replacing it with a new geometry all should be fine. Anyway Tahnk you again. I should be more carefull in using cursors.
... View more
09-20-2018
07:10 AM
|
0
|
0
|
741
|
POST
|
Yes!, it works! Thank you. The problem is probably hidden in nested cursors. I also solved with a workaround. First duplicating records and after with a (not nested ) UpdateCursor updating the geometry, but your solution is more compact and I think I will use it. Thank you again.
... View more
09-20-2018
06:46 AM
|
0
|
2
|
741
|
POST
|
My version is 10.4 but I think this cannot be the problem. I tried your code and all seems ok also for me, so the problem is not here. This code should duplicate a record and change the shape with the segment but here you should see the trouble. outpathname = "in_memory\polyline" polyline = arcpy.AsShape("""{"paths":[[[686187.19259999972,4929374.2093000002],[686221.91579999961,4929363.8212000001],[686224.60580000002,4929363.6297999993],[686227.87069999985,4929364.5913999993],[686230.85759999976,4929365.9749999996]]],"spatialReference":{"wkid":25832,"latestWkid":25832}}""", True) arcpy.CopyFeatures_management(polyline,outpathname) SR = arcpy.Describe(outpathname).spatialReference with arcpy.da.SearchCursor(outpathname, ['SHAPE@','*'] ) as cursor: with arcpy.da.InsertCursor(outpathname, ['SHAPE@','*'] ) as icur: for row in cursor: polyline = row[0] #print polyline segment = arcpy.Polyline(arcpy.Array([polyline.firstPoint,polyline.lastPoint]),SR) row = list(row) row[0] = segment icur.insertRow(row) Please give me a feedbak. Thank you!
... View more
09-19-2018
01:44 PM
|
0
|
5
|
741
|
POST
|
SR = arcpy.Describe(linepathname).spatialReference polyline = arcpy.AsShape("""{"paths":[[[686187.19259999972,4929374.2093000002],[686221.91579999961,4929363.8212000001],[686224.60580000002,4929363.6297999993],[686227.87069999985,4929364.5913999993],[686230.85759999976,4929365.9749999996]]],"spatialReference":{"wkid":25832,"latestWkid":25832}}""", True) #segment = arcpy.Polyline(arcpy.Array([polyline.firstPoint,polyline.lastPoint]),SR) segment = arcpy.AsShape("""{"paths":[[[686187.19259999972,4929374.2093000002],[686230.85759999976,4929365.9749999996]]],"spatialReference":{"wkid":25832,"latestWkid":25832}}""", True) I have tried to create a simple line that join the first point and the last point of the polyline but the render on the map is wrong (see the Image). I have an offset and I cant figure the problem. (The spatial reference it's the same) Anyone can give me some suggestion?
... View more
09-19-2018
05:52 AM
|
0
|
7
|
853
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|