Geographic Information Systems Asked by ElizaC on May 14, 2021
I am trying to trim each polyline in a shapefile down to the first 15 feet of each line. The segmentAlongLine
method was suggested to me, but this code is getting the AttributeError: 'list' object has no attribute 'segmentAlongLine'
.
SHAPE@
in this case is a polyline object… Why is it calling it a list and why isn’t segmentAlongLine
working? I have found questions about this error but none of the answers seem to apply to my issue.
with arcpy.da.UpdateCursor(fc,"SHAPE@") as cursor:
for row in cursor:
row.segmentAlongLine(0,15)
What if you try:
errors = []
with arcpy.da.UpdateCursor(fc,["SHAPE@", "OID@"]) as cursor:
for row in cursor:
try:
row[0].segmentAlongLine(0,15)
except AttributeError:
errors.append(row)
What is in errors
list?
And you are not changing anything with your code. You need to assign row[0] a new value and cursor.updateRow(row)
Correct answer by BERA on May 14, 2021
row
is a list containing the shape of the feature. Use row[0].segmentAlongLine(0,15)
.
Answered by Kadir Şahbaz on May 14, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP