<?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 Python - Create Buffer Issue in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcgis-online-notebook-python-create-buffer-issue/m-p/1635939#M74530</link>
    <description>&lt;P&gt;I think the issue is the&amp;nbsp;geometry format, needing conversion before buffering.&lt;/P&gt;&lt;P&gt;Untested.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;from arcgis.geometry import Geometry

# After your buffer operation:
buffer_result = arcgis_buffer(geometries=[geom_dict], ...)

if buffer_result:
    buffered_geom = Geometry(buffer_result[0])  # Convert to Geometry object&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;# Convert input geometry BEFORE buffering
from arcgis.geometry import Polyline, Geometry

for feat in new_features:
    try:
        # Convert source geometry first
        geom = Geometry(feat.geometry)  # or Polyline(feat.geometry)
        
        # Buffer the converted geometry
        buffer_result = arcgis_buffer(
            geometries=[geom],
            in_sr=4326,
            distances=[buffer_distance],
            unit=9002,
            union_results=False,
            out_sr=4326
        )
        
        # No need to convert buffer_result if just storing it
        buffered_geom = buffer_result[0]
        
        # Rest of your code...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Jul 2025 14:32:38 GMT</pubDate>
    <dc:creator>TonyAlmeida</dc:creator>
    <dc:date>2025-07-24T14:32:38Z</dc:date>
    <item>
      <title>ArcGIS Online Notebook Python - Create Buffer Issue</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-online-notebook-python-create-buffer-issue/m-p/1635934#M74529</link>
      <description>&lt;P&gt;Hey members,&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a big ask, so feel free to ignore. Although, if there is some knowledge you can throw my way I would be greatly appreciative. I have been going back and forth with errors on the buffer block and come to the conclusion that I am close. Anyhow, I will continue and thanks in advance if you see and help with this issue.&lt;/P&gt;&lt;P&gt;Sincerely, Christopher&lt;/P&gt;&lt;P&gt;Here is the logging information:&lt;/P&gt;&lt;PRE&gt;2025-07-24 13:59:14,552 - INFO - Connected to layer at https://services3.arcgis.com/yrIZ0Nv0mSGTWJsH/arcgis/rest/services/Forest_Health_Ground_Survey/FeatureServer/89 successfully.
2025-07-24 13:59:14,553 - INFO - Connected to layer at &lt;A href="https://services3.arcgis.com/yrIZ0Nv0mSGTWJsH/arcgis/rest/services/Forest_Health_Ground_Survey_Buffer/FeatureServer/90" target="_blank" rel="noopener"&gt;https://services3.arcgis.com/yrIZ0Nv0mSGTWJsH/arcgis/rest/services/Forest_Health_Ground_Survey_Buffer/FeatureServer/90&lt;/A&gt; successfully.
2025-07-24 13:59:14,553 - INFO - All layers connected successfully.
2025-07-24 13:59:14,795 - INFO - 0 existing buffer features found.
2025-07-24 13:59:14,796 - INFO - 2 new survey features to buffer.
2025-07-24 13:59:15,071 - INFO - 0 existing buffer features found.
2025-07-24 13:59:15,071 - INFO - Feature Attributes:
2025-07-24 13:59:15,072 - INFO -   OBJECTID: 1
2025-07-24 13:59:15,073 - INFO -   County: Oklahoma
2025-07-24 13:59:15,074 - INFO -   FFY: 2025
2025-07-24 13:59:15,074 - INFO -   Forester: Chris Mask
2025-07-24 13:59:15,075 - INFO -   Path_Type: Road
2025-07-24 13:59:15,076 - INFO -   GlobalID: 45932289-83cf-4f5b-84c4-18ff587df745
2025-07-24 13:59:15,077 - INFO -   Survey_Focus: Forest Health
2025-07-24 13:59:15,077 - INFO -   Shape__Length: 28861.232481266623
2025-07-24 13:59:15,079 - INFO -   CreationDate: 1753293465437
2025-07-24 13:59:15,079 - INFO -   Creator: CMask_OKForestry
2025-07-24 13:59:15,080 - INFO -   EditDate: 1753293465437
2025-07-24 13:59:15,081 - INFO -   Editor: CMask_OKForestry
2025-07-24 13:59:15,081 - INFO - Feature Geometry:
2025-07-24 13:59:15,082 - INFO - {'paths': [[[-97.373237047319, 35.4334389290588], [-97.284186283348, 35.402255788017]]], 'spatialReference': {'wkid': 4326, 'latestWkid': 4326}}
2025-07-24 13:59:15,083 - INFO - Feature Attributes:
2025-07-24 13:59:15,085 - INFO -   OBJECTID: 2
2025-07-24 13:59:15,086 - INFO -   County: Pottawatomie
2025-07-24 13:59:15,086 - INFO -   FFY: 2025
2025-07-24 13:59:15,087 - INFO -   Forester: Chris Mask
2025-07-24 13:59:15,088 - INFO -   Path_Type: Trail
2025-07-24 13:59:15,089 - INFO -   GlobalID: e21a7e3e-c67c-42af-ad37-833f6cf4c5d3
2025-07-24 13:59:15,089 - INFO -   Survey_Focus: Health
2025-07-24 13:59:15,090 - INFO -   Shape__Length: 58601.425958823864
2025-07-24 13:59:15,090 - INFO -   CreationDate: 1753295800100
2025-07-24 13:59:15,091 - INFO -   Creator: CMask_OKForestry
2025-07-24 13:59:15,093 - INFO -   EditDate: 1753295800100
2025-07-24 13:59:15,093 - INFO -   Editor: CMask_OKForestry
2025-07-24 13:59:15,094 - INFO - Feature Geometry:
2025-07-24 13:59:15,094 - INFO - {'paths': [[[-97.1184390528449, 35.2597503589496], [-96.9221785207107, 35.2581636601495]]], 'spatialReference': {'wkid': 4326, 'latestWkid': 4326}}
2025-07-24 13:59:15,249 - ERROR - Error buffering feature 45932289-83cf-4f5b-84c4-18ff587df745: list indices must be integers or slices, not str
2025-07-24 13:59:15,250 - ERROR - Error buffering feature e21a7e3e-c67c-42af-ad37-833f6cf4c5d3: list indices must be integers or slices, not str
2025-07-24 13:59:15,250 - INFO - No new buffer features to add.&lt;/PRE&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;P&gt;from arcgis.gis import GIS&lt;BR /&gt;from arcgis.features import FeatureLayer&lt;BR /&gt;#from shapely.geometry import Point, Polygon&lt;BR /&gt;from arcgis.geometry import Geometry, Polyline, Polygon, LengthUnits, Point, project, lengths, areas_and_lengths, union&lt;BR /&gt;from arcgis.geometry.filters import intersects, contains, overlaps, crosses, touches, within&lt;BR /&gt;from arcgis.geometry.filters import envelope_intersects, index_intersects&lt;BR /&gt;from arcgis.geoenrichment import Country&lt;BR /&gt;import pandas as pd&lt;BR /&gt;import logging&lt;BR /&gt;from arcgis.geometry import buffer as arcgis_buffer&lt;/P&gt;&lt;P&gt;# Configure logging&lt;BR /&gt;logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")&lt;/P&gt;&lt;P&gt;# Connect to your active ArcGIS Online session (assumes you're signed in via Pro or Notebook)&lt;BR /&gt;gis = GIS("home")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# Function to connect to layers by URL&lt;BR /&gt;def connect_layers_by_url(*urls):&lt;BR /&gt;try:&lt;BR /&gt;layers = []&lt;BR /&gt;for url in urls:&lt;BR /&gt;# Connect to each FeatureLayer using the GIS object&lt;BR /&gt;layer = FeatureLayer(url, gis=gis)&lt;BR /&gt;layers.append(layer)&lt;BR /&gt;logging.info(f"Connected to layer at {url} successfully.")&lt;BR /&gt;return layers&lt;BR /&gt;except Exception as e:&lt;BR /&gt;logging.error(f"Error connecting to layers: {e}")&lt;BR /&gt;return [None] * len(urls)&lt;/P&gt;&lt;P&gt;# Define layer URLs&lt;BR /&gt;Survey_url = "&lt;A href="https://services3.arcgis.com/yrIZ0Nv0mSGTWJsH/arcgis/rest/services/Forest_Health_Ground_Survey/FeatureServer/89" target="_blank"&gt;https://services3.arcgis.com/yrIZ0Nv0mSGTWJsH/arcgis/rest/services/Forest_Health_Ground_Survey/FeatureServer/89&lt;/A&gt;"&lt;BR /&gt;SurveyBuffer_layer_url = "&lt;A href="https://services3.arcgis.com/yrIZ0Nv0mSGTWJsH/arcgis/rest/services/Forest_Health_Ground_Survey_Buffer/FeatureServer/90" target="_blank"&gt;https://services3.arcgis.com/yrIZ0Nv0mSGTWJsH/arcgis/rest/services/Forest_Health_Ground_Survey_Buffer/FeatureServer/90&lt;/A&gt;"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;# Connect to layers with authentication&lt;BR /&gt;Survey_layer, SurveyBuffer_layer = connect_layers_by_url(&lt;BR /&gt;Survey_url, SurveyBuffer_layer_url&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;# Validate layer connections&lt;BR /&gt;if any(layer is None for layer in [Survey_layer, SurveyBuffer_layer]):&lt;BR /&gt;logging.error("One or more layers failed to connect. Please check the URLs or GIS credentials.")&lt;BR /&gt;else:&lt;BR /&gt;logging.info("All layers connected successfully.")&lt;/P&gt;&lt;P&gt;all_features = Survey_layer.query(where="1=1", out_fields="*", return_geometry=True, out_sr=4326).features&lt;BR /&gt;new_features = [f for f in all_features if f.attributes["GlobalID"] not in existing_ids]&lt;/P&gt;&lt;P&gt;logging.info(f"{len(existing_ids)} existing buffer features found.")&lt;BR /&gt;logging.info(f"{len(new_features)} new survey features to buffer.")&lt;/P&gt;&lt;P&gt;# Step 1: Get existing FHGS_IDs&lt;BR /&gt;existing_ids = set()&lt;BR /&gt;buffer_features = SurveyBuffer_layer.query(where="1=1", out_fields="FHGS_ID").features&lt;BR /&gt;for feat in buffer_features:&lt;BR /&gt;fid = feat.attributes.get("FHGS_ID")&lt;BR /&gt;if fid:&lt;BR /&gt;existing_ids.add(fid)&lt;/P&gt;&lt;P&gt;logging.info(f"{len(existing_ids)} existing buffer features found.")&lt;/P&gt;&lt;P&gt;#print geometry&lt;BR /&gt;for feature in new_features:&lt;BR /&gt;attrs = feature.attributes&lt;BR /&gt;geom = feature.geometry&lt;BR /&gt;&lt;BR /&gt;logging.info("Feature Attributes:")&lt;BR /&gt;for key, value in attrs.items():&lt;BR /&gt;logging.info(f" {key}: {value}")&lt;BR /&gt;&lt;BR /&gt;logging.info("Feature Geometry:")&lt;BR /&gt;logging.info(geom)&lt;/P&gt;&lt;P&gt;# Step 2: Get new features from Survey_layer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Step 3: Process each new feature and create buffers&lt;BR /&gt;new_buffer_features = []&lt;/P&gt;&lt;P&gt;for feat in new_features:&lt;BR /&gt;try:&lt;BR /&gt;attrs = feat.attributes&lt;BR /&gt;geom_dict = feat.geometry&lt;BR /&gt;path_type = attrs.get("Path_Type", "")&lt;BR /&gt;&lt;BR /&gt;# Set buffer distance in feet&lt;BR /&gt;if path_type == "Road":&lt;BR /&gt;buffer_distance = 100&lt;BR /&gt;elif path_type == "Trail":&lt;BR /&gt;buffer_distance = 50&lt;BR /&gt;else:&lt;BR /&gt;buffer_distance = 0&lt;/P&gt;&lt;P&gt;if buffer_distance == 0:&lt;BR /&gt;logging.warning(f"Skipping feature with unknown Path_Type: {path_type}")&lt;BR /&gt;continue&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;buffer_result = arcgis_buffer(&lt;BR /&gt;geometries=[geom_dict],&lt;BR /&gt;in_sr=4326,&lt;BR /&gt;distances=[buffer_distance],&lt;BR /&gt;unit=9002, # unit can also be numeric (e.g. 9002 for feet)&lt;BR /&gt;union_results=False,&lt;BR /&gt;out_sr=4326&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;if not buffer_result or not buffer_result[0]:&lt;BR /&gt;logging.error(f"No buffered geometry returned for feature {attrs.get('GlobalID')}")&lt;BR /&gt;continue&lt;/P&gt;&lt;P&gt;buffered_geom = buffer_result[0]&lt;/P&gt;&lt;P&gt;# Calculate area in square feet, then convert to acres&lt;BR /&gt;area_result = areas_and_lengths(&lt;BR /&gt;[buffered_geom],&lt;BR /&gt;length_unit='FEET',&lt;BR /&gt;area_unit='SQUARE_FEET',&lt;BR /&gt;calculation_type='PLANAR'&lt;BR /&gt;)&lt;BR /&gt;acres = area_result['areas'][0] / 43560 # Convert sq ft to acres&lt;/P&gt;&lt;P&gt;# Prepare new feature&lt;BR /&gt;new_feature = {&lt;BR /&gt;"geometry": buffered_geom,&lt;BR /&gt;"attributes": {&lt;BR /&gt;"County": attrs.get("County"),&lt;BR /&gt;"FFY": attrs.get("FFY"),&lt;BR /&gt;"Forester": attrs.get("Forester"),&lt;BR /&gt;"Path_Type": path_type,&lt;BR /&gt;"FHGS_ID": attrs.get("GlobalID"),&lt;BR /&gt;"Acres": round(acres, 2)&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;new_buffer_features.append(new_feature)&lt;/P&gt;&lt;P&gt;except Exception as e:&lt;BR /&gt;logging.error(f"Error buffering feature {attrs.get('GlobalID', 'unknown')}: {str(e)}")&lt;/P&gt;&lt;P&gt;# Step 4: Add new buffered features to SurveyBuffer_layer&lt;BR /&gt;if new_buffer_features:&lt;BR /&gt;add_result = SurveyBuffer_layer.edit_features(adds=new_buffer_features)&lt;BR /&gt;logging.info(f"Added {len(new_buffer_features)} new buffer features.")&lt;BR /&gt;else:&lt;BR /&gt;logging.info("No new buffer features to add.")&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 14:12:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-online-notebook-python-create-buffer-issue/m-p/1635934#M74529</guid>
      <dc:creator>ChristopherMask</dc:creator>
      <dc:date>2025-07-24T14:12:01Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Online Notebook Python - Create Buffer Issue</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-online-notebook-python-create-buffer-issue/m-p/1635939#M74530</link>
      <description>&lt;P&gt;I think the issue is the&amp;nbsp;geometry format, needing conversion before buffering.&lt;/P&gt;&lt;P&gt;Untested.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;from arcgis.geometry import Geometry

# After your buffer operation:
buffer_result = arcgis_buffer(geometries=[geom_dict], ...)

if buffer_result:
    buffered_geom = Geometry(buffer_result[0])  # Convert to Geometry object&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;# Convert input geometry BEFORE buffering
from arcgis.geometry import Polyline, Geometry

for feat in new_features:
    try:
        # Convert source geometry first
        geom = Geometry(feat.geometry)  # or Polyline(feat.geometry)
        
        # Buffer the converted geometry
        buffer_result = arcgis_buffer(
            geometries=[geom],
            in_sr=4326,
            distances=[buffer_distance],
            unit=9002,
            union_results=False,
            out_sr=4326
        )
        
        # No need to convert buffer_result if just storing it
        buffered_geom = buffer_result[0]
        
        # Rest of your code...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 14:32:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-online-notebook-python-create-buffer-issue/m-p/1635939#M74530</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-07-24T14:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Online Notebook Python - Create Buffer Issue</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-online-notebook-python-create-buffer-issue/m-p/1636001#M74531</link>
      <description>&lt;P&gt;That fixed the error, so thank you very much for your assistance. Although, I get this now&lt;/P&gt;&lt;P&gt;Logging information:&lt;/P&gt;&lt;PRE&gt;2025-07-24 16:09:38,921 - INFO - Connected to layer at https://services3.arcgis.com/yrIZ0Nv0mSGTWJsH/arcgis/rest/services/Forest_Health_Ground_Survey/FeatureServer/89 successfully.
2025-07-24 16:09:38,921 - INFO - Connected to layer at &lt;A href="https://services3.arcgis.com/yrIZ0Nv0mSGTWJsH/arcgis/rest/services/Forest_Health_Ground_Survey_Buffer/FeatureServer/90" target="_blank" rel="noopener"&gt;https://services3.arcgis.com/yrIZ0Nv0mSGTWJsH/arcgis/rest/services/Forest_Health_Ground_Survey_Buffer/FeatureServer/90&lt;/A&gt; successfully.
2025-07-24 16:09:38,922 - INFO - All layers connected successfully.
2025-07-24 16:09:39,365 - INFO - 0 existing buffer features found.
2025-07-24 16:09:39,366 - INFO - Feature Attributes:
2025-07-24 16:09:39,367 - INFO -   OBJECTID: 1
2025-07-24 16:09:39,368 - INFO -   GlobalID: 45932289-83cf-4f5b-84c4-18ff587df745
2025-07-24 16:09:39,368 - INFO -   County: Oklahoma
2025-07-24 16:09:39,369 - INFO -   FFY: 2025
2025-07-24 16:09:39,370 - INFO -   Forester: Chris Mask
2025-07-24 16:09:39,371 - INFO -   Path_Type: Road
2025-07-24 16:09:39,371 - INFO - Feature Geometry:
2025-07-24 16:09:39,372 - INFO - {'paths': [[[2155227.05450027, 158381.454784061], [2181840.23027768, 147214.108842507]]], 'spatialReference': {'wkid': 2911, 'latestWkid': 2911}}
2025-07-24 16:09:39,373 - INFO - Feature Attributes:
2025-07-24 16:09:39,373 - INFO -   OBJECTID: 2
2025-07-24 16:09:39,375 - INFO -   GlobalID: e21a7e3e-c67c-42af-ad37-833f6cf4c5d3
2025-07-24 16:09:39,375 - INFO -   County: Pottawatomie
2025-07-24 16:09:39,376 - INFO -   FFY: 2025
2025-07-24 16:09:39,377 - INFO -   Forester: Chris Mask
2025-07-24 16:09:39,377 - INFO -   Path_Type: Trail
2025-07-24 16:09:39,378 - INFO - Feature Geometry:
2025-07-24 16:09:39,379 - INFO - {'paths': [[[2231708.58234967, 95748.3537223102], [2290310.00669738, 95762.0951357639]]], 'spatialReference': {'wkid': 2911, 'latestWkid': 2911}}
2025-07-24 16:09:39,602 - INFO - 2 new survey features to buffer.
2025-07-24 16:09:39,603 - INFO - Geometry Type: Polyline
2025-07-24 16:09:39,817 - ERROR - No buffered geometry returned for feature 45932289-83cf-4f5b-84c4-18ff587df745
2025-07-24 16:09:39,818 - INFO - Geometry Type: Polyline
2025-07-24 16:09:40,807 - ERROR - No buffered geometry returned for feature e21a7e3e-c67c-42af-ad37-833f6cf4c5d3
2025-07-24 16:09:40,808 - INFO - No new buffer features to add.&lt;/PRE&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;for feat in new_features:&lt;BR /&gt;try:&lt;BR /&gt;attrs = feat.attributes&lt;BR /&gt;geom_dict = feat.geometry&lt;BR /&gt;path_type = attrs.get("Path_Type", "")&lt;BR /&gt;&lt;BR /&gt;# Set buffer distance in feet&lt;BR /&gt;if path_type == "Road":&lt;BR /&gt;buffer_distance = 100&lt;BR /&gt;elif path_type == "Trail":&lt;BR /&gt;buffer_distance = 50&lt;BR /&gt;else:&lt;BR /&gt;buffer_distance = 0&lt;/P&gt;&lt;P&gt;if buffer_distance == 0:&lt;BR /&gt;logging.warning(f"Skipping feature with unknown Path_Type: {path_type}")&lt;BR /&gt;continue&lt;/P&gt;&lt;P&gt;#Convert source geometry first&lt;BR /&gt;geom = Polyline(feat.geometry) # Or Geometry(feat.geometry)&lt;BR /&gt;logging.info(f"Geometry Type: {geom.type}") # Should be 'polyline'&lt;/P&gt;&lt;P&gt;# Project to Web Mercator (EPSG:3857) before buffering&lt;BR /&gt;projected_geom = project([geom], in_sr=4326, out_sr=3857)[0]&lt;/P&gt;&lt;P&gt;buffer_result = arcgis_buffer(&lt;BR /&gt;geometries=[projected_geom],&lt;BR /&gt;in_sr=3857,&lt;BR /&gt;distances=[buffer_distance],&lt;BR /&gt;unit=9002,&lt;BR /&gt;union_results=False,&lt;BR /&gt;out_sr=3857&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;if not buffer_result or not buffer_result[0]:&lt;BR /&gt;logging.error(f"No buffered geometry returned for feature {attrs.get('GlobalID')}")&lt;BR /&gt;continue&lt;/P&gt;&lt;P&gt;#if buffer_result:&lt;BR /&gt;#buffered_geom = Geometry(buffer_result[0]) # Convert to Geometry object&lt;BR /&gt;#buffered_geom = project([Geometry(buffer_result[0])], in_sr=3857, out_sr=4326)[0]&lt;BR /&gt;#buffered_geom = buffer_result[0]&lt;/P&gt;&lt;P&gt;# Calculate area in square feet, then convert to acres&lt;BR /&gt;area_result = areas_and_lengths([buffered_geom], length_unit='FEET', area_unit='SQUARE_FEET', calculation_type='PLANAR')&lt;BR /&gt;acres = area_result['areas'][0] / 43560 # sq ft to acres&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jul 2025 16:12:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-online-notebook-python-create-buffer-issue/m-p/1636001#M74531</guid>
      <dc:creator>ChristopherMask</dc:creator>
      <dc:date>2025-07-24T16:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Online Notebook Python - Create Buffer Issue</title>
      <link>https://community.esri.com/t5/python-questions/arcgis-online-notebook-python-create-buffer-issue/m-p/1636065#M74532</link>
      <description>&lt;P&gt;arcgis_buffer is returning either none or [None}, check your&amp;nbsp;geometry projection and potentially incorrect spatial reference.&lt;/P&gt;&lt;P&gt;Add this before your loop to ensure compatibility&lt;/P&gt;&lt;LI-CODE lang="c"&gt;target_sr = SurveyBuffer_layer.properties.spatialReference['wkid']
if target_sr != 2911:
    logging.info(f"Note: Will project from 2911 to {target_sr} before saving")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;untested,&lt;/P&gt;&lt;LI-CODE lang="c"&gt;from arcgis.geometry import Polyline, Geometry
from arcgis.geometry.functions import buffer as arcgis_buffer, areas_and_lengths, project

# Get target layer's spatial reference ONCE before the loop
target_sr = SurveyBuffer_layer.properties.spatialReference['wkid']
if target_sr != 2911:
    logging.info(f"Note: Will project from 2911 to {target_sr} before saving")

for feat in new_features:
    try:
        attrs = feat.attributes
        geom_dict = feat.geometry
        path_type = attrs.get("Path_Type", "")
        
        # Set buffer distance in feet
        if path_type == "Road":
            buffer_distance = 100
        elif path_type == "Trail":
            buffer_distance = 50
        else:
            logging.warning(f"Skipping feature with unknown Path_Type: {path_type}")
            continue

        # 1. Create proper geometry object (using correct SRID from your data)
        geom = Polyline(geom_dict)  # Your data shows wkid=2911
        logging.info(f"Processing feature {attrs.get('GlobalID')} with geometry type: {geom.type}")
        
        # 2. Buffer in the original CRS (2911)
        buffer_result = arcgis_buffer(
            geometries=[geom],
            in_sr=2911,  # Oklahoma State Plane
            distances=[buffer_distance],
            unit=9002,   # Feet (appropriate for State Plane)
            union_results=False,
            out_sr=2911  # Keep buffer in same CRS initially
        )

        if not buffer_result or not buffer_result[0]:
            logging.error(f"No buffered geometry returned for feature {attrs.get('GlobalID')}")
            continue

        buffered_geom = buffer_result[0]
        
        # 3. Project to target CRS if different from 2911
        if target_sr != 2911:
            try:
                projected_geom = project(
                    [Geometry(buffered_geom)],
                    in_sr=2911,
                    out_sr=target_sr
                )[0]
                buffered_geom = projected_geom
                logging.info(f"Successfully projected geometry to SRID {target_sr}")
            except Exception as proj_error:
                logging.error(f"Projection failed for feature {attrs.get('GlobalID')}: {str(proj_error)}")
                continue

        # Calculate area (in original CRS for accuracy)
        try:
            area_result = areas_and_lengths(
                [buffered_geom if target_sr == 2911 else Geometry(buffer_result[0])],  # Use original buffer for calculation
                length_unit='FEET',
                area_unit='SQUARE_FEET',
                calculation_type='PLANAR'
            )
            acres = area_result['areas'][0] / 43560  # sq ft to acres
            logging.info(f"Calculated area: {acres:.2f} acres")
        except Exception as area_error:
            logging.warning(f"Area calculation failed for feature {attrs.get('GlobalID')}: {str(area_error)}")
            acres = 0

        # Prepare feature for addition
        new_feature = {
            "geometry": buffered_geom,
            "attributes": {
                "County": attrs.get("County"),
                "FFY": attrs.get("FFY"),
                "Forester": attrs.get("Forester"),
                "Path_Type": path_type,
                "FHGS_ID": attrs.get("GlobalID"),
                "Acres": round(acres, 2)
            }
        }
        
        new_buffer_features.append(new_feature)

    except Exception as e:
        logging.error(f"Error processing feature {attrs.get('GlobalID', 'unknown')}: {str(e)}", exc_info=True)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 24 Jul 2025 18:20:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcgis-online-notebook-python-create-buffer-issue/m-p/1636065#M74532</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-07-24T18:20:46Z</dc:date>
    </item>
  </channel>
</rss>

