<?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: ArcGIS Online Notebook how to create buffers and append against existing layer in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-online-notebook-how-to-create-buffers-and/m-p/1543684#M10717</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/417766"&gt;@Clubdebambos&lt;/a&gt;&amp;nbsp;. The amended geometry / units resolved the issue.&lt;/P&gt;&lt;P&gt;For each point, as we only have one buffer, here's the extra piece to create a polygon feature:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;        if buffers:
            new_polygon= {
                "geometry": buffers[0],
                "attributes": {
                    "parentglobalid": point.attributes["globalid"]
                    # more attributes here
                }
            }
            # Append the new feature to the polygon layer
            polygon_layer.edit_features(adds=[new_polygon])&lt;/LI-CODE&gt;</description>
    <pubDate>Sun, 29 Sep 2024 23:20:58 GMT</pubDate>
    <dc:creator>ChristopherCounsell</dc:creator>
    <dc:date>2024-09-29T23:20:58Z</dc:date>
    <item>
      <title>ArcGIS Online Notebook how to create buffers and append against existing layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-online-notebook-how-to-create-buffers-and/m-p/1542280#M10695</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a Hosted Feature Layer in ArcGIS Online, with a point layer and a polygon layer.&lt;/P&gt;&lt;P&gt;I am looking to run an ArcGIS Notebook as a task that will:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Query the point layer where processed=no&lt;/LI&gt;&lt;LI&gt;For each point, buffer by a point attribute ("distance_field")&lt;/LI&gt;&lt;LI&gt;Take the buffer and append to the polygon layer, passing through the distance_field value, a type field and a globalid into parentglobalid. This is required for subsequent processing (and deleting related buffers when the point is updated).&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I am having difficulty with the buffer() and use_proximity.create_buffers(). No matter what I do the input geometry seems to be recognized as invalid. Typical error messages are invalid geometry or&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;PRE&gt;an error occured with:list indices must be integers or slices, not str&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;Here is a basic script:&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
from arcgis.features import FeatureLayer
from arcgis.geometry import buffer
from arcgis.features import use_proximity

gis = GIS("home")

# Get our layers
layer_item = gis.content.get("xyzxyzxyz")
point_sublayer = layer_item.layers[1]
polygon_sublayer = layer_item.layers[2]

# Query our point layer
# Can set our_sr to 4326 or 3857. WGS84 or projected.
points = point_sublayer.query(where="1=1", out_fields="*", return_geometry=True,out_sr = 4326)

try:
    for point in points:
        p = point.geometry
        print(type(p))
        buffers = buffer(geometries=[p], distances=[5], unit='meters',out_sr=4326) # fails   
        # extra bit would go here to append against polygon
except Exception as e:
    print(f"an error occured with:{str(e)}")

    
 &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe it is because the input is a feature, not a featurecollection or other valid type but I'm not sure how to handle it otherwise.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 01:02:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-online-notebook-how-to-create-buffers-and/m-p/1542280#M10695</guid>
      <dc:creator>ChristopherCounsell</dc:creator>
      <dc:date>2024-09-25T01:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Online Notebook how to create buffers and append against existing layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-online-notebook-how-to-create-buffers-and/m-p/1542391#M10697</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/412943"&gt;@ChristopherCounsell&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got the same error from your code above. See code snippet below for using the geometry.buffer to return the geometry for the buffer polygon. Most notably use the LengthUnits enum and the Point geometry.&lt;/P&gt;&lt;P&gt;Let me know if this works on your end.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.geometry import LengthUnits
from arcgis.geometry import Point

...

for point in points:
    try:
        p = Point(point.geometry)
        buffers = buffer(geometries=[p], distances=[5], unit=LengthUnits.METER.value, in_sr=4326)
        print(buffers)
    except Exception as e:
        print(f"an error occured with: {str(e)}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have inspired this &lt;A href="https://learn.finaldraftmapping.com/buffer-points-in-arcgis-online-and-append-into-a-polygon-feature-layer-using-the-arcgis-api-for-python/" target="_blank" rel="noopener"&gt;blog post&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;All the best,&lt;/P&gt;&lt;P&gt;Glen&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 14:34:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-online-notebook-how-to-create-buffers-and/m-p/1542391#M10697</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2024-09-25T14:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Online Notebook how to create buffers and append against existing layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-online-notebook-how-to-create-buffers-and/m-p/1543684#M10717</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/417766"&gt;@Clubdebambos&lt;/a&gt;&amp;nbsp;. The amended geometry / units resolved the issue.&lt;/P&gt;&lt;P&gt;For each point, as we only have one buffer, here's the extra piece to create a polygon feature:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;        if buffers:
            new_polygon= {
                "geometry": buffers[0],
                "attributes": {
                    "parentglobalid": point.attributes["globalid"]
                    # more attributes here
                }
            }
            # Append the new feature to the polygon layer
            polygon_layer.edit_features(adds=[new_polygon])&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 29 Sep 2024 23:20:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-online-notebook-how-to-create-buffers-and/m-p/1543684#M10717</guid>
      <dc:creator>ChristopherCounsell</dc:creator>
      <dc:date>2024-09-29T23:20:58Z</dc:date>
    </item>
  </channel>
</rss>

