<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Update feature geometry? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/update-feature-geometry/m-p/1718782#M12015</link>
    <description>&lt;P&gt;That's an interesting thought and I'll check it out, but it works with only four points in normal arcpy&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.UpdateCursor(inspectbl,
                           ['SHAPE@', "mapminx", "mapminy",
                            "mapmaxx", "mapmaxy", "OID@"],
                           where_clause= where_clause) as cursor:
    for row in cursor:
        lowleft = arcpy.Point(row[1], row[2])
        upleft = arcpy.Point(row[1], row[4])
        upright = arcpy.Point(row[3], row[4])
        lowright = arcpy.Point(row[3], row[2])
        corners = arcpy.Array([lowleft, upleft, upright, lowright])
        row[0] = arcpy.Geometry("polygon", corners)
        cursor.updateRow(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;so I'm not certain that's it&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Aug 2026 18:59:47 GMT</pubDate>
    <dc:creator>AlfredBaldenweck</dc:creator>
    <dc:date>2026-08-05T18:59:47Z</dc:date>
    <item>
      <title>Update feature geometry?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/update-feature-geometry/m-p/1718724#M12011</link>
      <description>&lt;P&gt;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).&lt;/P&gt;&lt;P&gt;I can do this with traditional arcpy, but I'm running into issues when trying to do it with the arcgis module.&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The documentation does not have any examples of actually updating geometry the way that you can update attributes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have any pointers? Thanks&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# 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)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 05 Aug 2026 16:23:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/update-feature-geometry/m-p/1718724#M12011</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2026-08-05T16:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: Update feature geometry?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/update-feature-geometry/m-p/1718737#M12012</link>
      <description>&lt;P&gt;Might be worth using the &lt;FONT face="courier new,courier"&gt;as_dict&lt;/FONT&gt; instance method and &lt;FONT face="courier new,courier"&gt;from_dict&lt;/FONT&gt; class method to create a new feature with matching attributes instead of editing the original object. Heavy handed but if it works, it works!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2026 17:02:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/update-feature-geometry/m-p/1718737#M12012</guid>
      <dc:creator>DavidSolari</dc:creator>
      <dc:date>2026-08-05T17:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: Update feature geometry?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/update-feature-geometry/m-p/1718779#M12014</link>
      <description>&lt;P&gt;I might be mistaken about this, but I don't think your polygons are valid.&amp;nbsp; I'm pretty sure the first point needs to be repeated as the last point to close it out, like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;corners = [lowleft, upleft, upright, lowright, lowleft]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2026 18:57:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/update-feature-geometry/m-p/1718779#M12014</guid>
      <dc:creator>MobiusSnake</dc:creator>
      <dc:date>2026-08-05T18:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: Update feature geometry?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/update-feature-geometry/m-p/1718782#M12015</link>
      <description>&lt;P&gt;That's an interesting thought and I'll check it out, but it works with only four points in normal arcpy&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.UpdateCursor(inspectbl,
                           ['SHAPE@', "mapminx", "mapminy",
                            "mapmaxx", "mapmaxy", "OID@"],
                           where_clause= where_clause) as cursor:
    for row in cursor:
        lowleft = arcpy.Point(row[1], row[2])
        upleft = arcpy.Point(row[1], row[4])
        upright = arcpy.Point(row[3], row[4])
        lowright = arcpy.Point(row[3], row[2])
        corners = arcpy.Array([lowleft, upleft, upright, lowright])
        row[0] = arcpy.Geometry("polygon", corners)
        cursor.updateRow(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;so I'm not certain that's it&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2026 18:59:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/update-feature-geometry/m-p/1718782#M12015</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2026-08-05T18:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: Update feature geometry?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/update-feature-geometry/m-p/1718792#M12016</link>
      <description>&lt;P&gt;Ok, so as it turns out, it was not an issue of the final point, although I've added that just in case.&lt;/P&gt;&lt;P&gt;The actual issue was that I was not nesting the coordinates deep enough.&lt;/P&gt;&lt;P&gt;The "rings" needs to be a list of lists of coordinate pairs, like:&lt;/P&gt;&lt;PRE&gt;[[[x1,y1], [x2,y2]]]&lt;/PRE&gt;&lt;P&gt;I had it as&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[[x1,y1, [x2, y2]]&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;Final working is&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# 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
    # arcgis.geometry.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, lowleft]]

    geo = arcgis.geometry.Geometry({"rings":corners,
                                    "spatial_reference":
                                        {"wkid":spatref}})

    insp.set_value(field_name="shape",
                   value= geo)
x = inspectFL.edit_features(updates=inspectFS,
                            use_global_ids=True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks everyone&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2026 19:24:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/update-feature-geometry/m-p/1718792#M12016</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2026-08-05T19:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Update feature geometry?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/update-feature-geometry/m-p/1719180#M12017</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/458875"&gt;@AlfredBaldenweck&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Edit: read the original post wrong so never mind &lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt; I see you're reading the coordinates from the attributes and not generating from the geometry. I'll wake up at some point today.&lt;/P&gt;&lt;P&gt;Anyway, you can still use the Envelope to help build the polygons rather that messing around with nesting.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.geometry import Geometry, Envelope, SpatialReference

## get attribute values
minx = insp.attributes["mapminx"]
maxx = insp.attributes["mapmaxx"]
miny = insp.attributes["mapminy"]
maxy = insp.attributes["mapmaxy"]

## get srs
spatref = inspectFS.spatial_reference

## create the polygon from an Envelope object
polygon = Envelope(
    {
        'xmin': minx, 'xmax': maxx, 'ymin': miny, 'ymax': maxy,
        'spatialReference' : SpatialReference(spatref)
    }
).polygon

## create the Geometry object
geo = Geometry(polygon)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Original reply: You don't need to build the geometry definition yourself, the API can handle that with the Geometry and Envelope classes. This handles the geometry and the same srs.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
from arcgis.features import FeatureLayer
from arcgis.geometry import Geometry

## access AGOL or Portal
agol = GIS("home")

## feature layer url
fl_url = "FL_URL"

## create a FeatureLayer object
fl = FeatureLayer(
    url = fl_url,
    gis = agol
)

## query the polygons to update
fset = fl.query()

## update the geometry to the bbox / envelope
for feature in fset.features:
    feature.geometry = Geometry(feature.geometry).envelope.polygon

## update the features
fl.edit_features(
    updates = fset
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the best,&lt;/P&gt;&lt;P&gt;Glen&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2026 08:47:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/update-feature-geometry/m-p/1719180#M12017</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2026-08-07T08:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: Update feature geometry?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/update-feature-geometry/m-p/1719268#M12018</link>
      <description>&lt;P&gt;That is a much nicer way to accomplish it, thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2026 15:13:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/update-feature-geometry/m-p/1719268#M12018</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2026-08-07T15:13:20Z</dc:date>
    </item>
  </channel>
</rss>

