Fairly new to python and I have a issue with writing new values to an existing text field in a feature class/shapefile. I want to update the existing text values by taking the Shape@ geometry of the polygon and making a series of text values seperated by a comma. I got it to work to create the text line and I can write the lines to a file - but now I want to take that text string and replace the values in a field that are already there using UpdateCursor. I want to make sure that all the polygon vertices are written to one filed, then move onto the next polygon as well - here I am trying to compare the OID's - if they change then move on. I am having issues accomplishing that feat - I can get the values to display in the python window - but then I get a "Runtime error Traceback (most recent call last): File "", line 21, in TypeError: value #1 - unsupported type: list"
Here is my code so far:
import arcpy
infc = "H:\GIST_8125\Oil_Gas\Gail_test\clip_project.shp"
for row in arcpy.da.SearchCursor(infc, ["OID@", "SHAPE@", "Coord_stri"]):
# iterate through polygon parts
partnum = 0
for part in row [1]:
# list polygon part points
for pnt in part:
print (str(pnt.X) + ',' + str(pnt.Y))
partnum += 1
# update coord_string
with arcpy.da.UpdateCursor(infc, ["OID@", "Coord_stri"]) as uCursor:
#iterate through rows and update values
for row in uCursor:
if row [0] == row [0]:
row [1] = ([pnt.X, pnt.Y])
uCursor.updateRow(row)
del uCursor, row
The first part of the polygon is correctly being written to the field - now just need to find a way to write the 4 other points to the same line:
import arcpy
infc = "H:\GIST_8125\Oil_Gas\Gail_test\clip_project.shp"
uCursor = arcpy.da.UpdateCursor(infc, ["OID@", "SHAPE@", "Coord_stri"])
for row in uCursor:
# iterate through polygon parts
partnum = 0
for part in row [1]:
# list polygon part points
for pnt in part:
print (str(pnt.X) + ',' + str(pnt.Y))
row[2] = (str(pnt.X) + ',' + str(pnt.Y))
uCursor.updateRow(row)
partnum += 1
del uCursor, row
coordlist = [pnt.X, pnt.Y]
coordstr = ",".join(coordlist)
row[1] = coordstr
. – smiller May 3 '18 at 15:38