I have a script that is supposed to replace the geometry of a polygon with a new polygon constructed by reading some of its fields (minX, minY, maxX, maxY).
I can do this with traditional arcpy, but I'm running into issues when trying to do it with the arcgis module.
Specifically, I either get no edits to the geometry if I include a spatial reference OR I get a "read-only" error if I include the spatial reference.
The documentation does not have any examples of actually updating geometry the way that you can update attributes.
Does anyone have any pointers? Thanks
# Get inspectbl as arcgis Featureset
inspectFL = arcgis.features.FeatureLayer(inspectbl,
gis=portal)
inspectFS = inspectFL.query(where=where_clause)
spatref = inspectFS.spatial_reference
for insp in inspectFS:
# Convert arcgis.feature geometry into
# arcpy Geometry.
lowleft = [insp.attributes["mapminx"],
insp.attributes["mapminy"]]
upleft = [insp.attributes["mapminx"],
insp.attributes["mapmaxy"]]
upright = [insp.attributes["mapmaxx"],
insp.attributes["mapmaxy"]]
lowright =[insp.attributes["mapmaxx"], insp.attributes["mapminy"]]
corners = [lowleft, upleft, upright, lowright]
geo = arcgis.geometry.Polygon(corners, spatial_reference=spatref)
geo = arcgis.geometry.Geometry({"rings":corners,
"spatial_reference": {"wkid":spatref}})
insp.set_value(field_name="shape",
value= geo)
inspectFL.edit_features(updates=inspectFS,
use_global_ids=True)