<?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: Geoaccessor.from_df in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/geoaccessor-from-df/m-p/1132664#M6999</link>
    <description>&lt;P&gt;Just a wild guess, and not wanting to look up the help just yet, and based on esri's use of "sr", I suspect that that is the reference to the spatial reference and not OBJECTID&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html?highlight=geoaccessor%20from_df#arcgis.features.GeoAccessor.from_df" target="_blank"&gt;arcgis.features module — arcgis 1.9.1 documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;sr&lt;/P&gt;&lt;P&gt;Optional integer. The WKID of the spatial reference.&lt;/P&gt;&lt;P&gt;(I had to check... just in case)&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jan 2022 23:31:13 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2022-01-11T23:31:13Z</dc:date>
    <item>
      <title>Geoaccessor.from_df</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/geoaccessor-from-df/m-p/1132657#M6998</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to convert a pandas dataframe that contains geometry (started from a feature class) to a spatially enabled dataframe using the GeoAccessor.from_df() function. See code snippet below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sdf = GeoAccessor.from_df(CompDF, sr = 'OBJECTID', geometry_column='SHAPE')
sdf.spatial.plot()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;referencing data as shown below for example:&lt;/P&gt;&lt;TABLE width="658px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="40px"&gt;OBJECTID&lt;/TD&gt;&lt;TD width="617px"&gt;SHAPE&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="40px"&gt;0&lt;/TD&gt;&lt;TD width="617px"&gt;{'x': 1587057.9938000003, 'y': 808409.8682000004, 'spatialReference': {'wkid': 32616, 'latestWkid': 32616}}&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;But I get a ValueError: Expected object or value&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PenelopeMitchell2_0-1641939553108.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/31239i99AA5C8AD946C143/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PenelopeMitchell2_0-1641939553108.png" alt="PenelopeMitchell2_0-1641939553108.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The data types are: OBJECTID is int64, SHAPE is object. I imagine the SHAPE dtype is throwing the error- if so, how do I get the SHAPE dtype to 'Geometry'?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or what is a good strategy to converting a dataframe with geometry information to a feature class or shapefile? I used to use GeoPandas but since I've upgraded my Pro version (2.8.2) the GeoPandas patch doesn't work in Pro due to compatibility issues.&lt;/P&gt;&lt;P&gt;Thanks for any insights.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 22:43:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/geoaccessor-from-df/m-p/1132657#M6998</guid>
      <dc:creator>PenelopeMitchell2</dc:creator>
      <dc:date>2022-01-11T22:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Geoaccessor.from_df</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/geoaccessor-from-df/m-p/1132664#M6999</link>
      <description>&lt;P&gt;Just a wild guess, and not wanting to look up the help just yet, and based on esri's use of "sr", I suspect that that is the reference to the spatial reference and not OBJECTID&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html?highlight=geoaccessor%20from_df#arcgis.features.GeoAccessor.from_df" target="_blank"&gt;arcgis.features module — arcgis 1.9.1 documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;sr&lt;/P&gt;&lt;P&gt;Optional integer. The WKID of the spatial reference.&lt;/P&gt;&lt;P&gt;(I had to check... just in case)&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 23:31:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/geoaccessor-from-df/m-p/1132664#M6999</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-01-11T23:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: Geoaccessor.from_df</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/geoaccessor-from-df/m-p/1132837#M7000</link>
      <description>&lt;P&gt;Is there some reason that you can't just use &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html#arcgis.features.GeoAccessor.from_featureclass" target="_blank"&gt;GeoAccessor.from_featureclass&lt;/A&gt; and leapfrog the non-spatial dataframe?&lt;/P&gt;&lt;P&gt;Using &lt;STRONG&gt;from_df&lt;/STRONG&gt; is specifically for dataframes with an &lt;EM&gt;address&lt;/EM&gt; string in them, and the resulting spatial dataframe will have the geocoded points.&lt;/P&gt;&lt;P&gt;Since your data looks like it's points, there are a couple ways you can do it. The first, and easiest, is to use &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html#arcgis.features.GeoAccessor.set_geometry" target="_blank"&gt;&lt;STRONG&gt;set_geometry&lt;/STRONG&gt;&lt;/A&gt;. You could even set the &lt;EM&gt;inplace&lt;/EM&gt; parameter to "True" and turn your non-spatial dataframe into a spatial dataframe if you wanted.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sdf = CompDF.spatial.set_geometry('SHAPE', 32616)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second method is more hacky, but I recall at least one or two situations where I had to go about it this way for some reason. Essentially, you take the 'SHAPE' column and split it up into multiple columns, then use &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html#arcgis.features.GeoAccessor.from_xy" target="_blank"&gt;&lt;STRONG&gt;from_xy&lt;/STRONG&gt;&lt;/A&gt; to create the spatial dataframe.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;xy_df = pd.concat([CompDF, CompDF['SHAPE'].apply(pd.Series)], axis=1)

sdf = GeoAccessor.from_xy(xy_df, 'x', 'y', 32616)&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1641992285054.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/31285iB2D139CAD28C393F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1641992285054.png" alt="jcarlson_0-1641992285054.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 12:58:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/geoaccessor-from-df/m-p/1132837#M7000</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-01-12T12:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: Geoaccessor.from_df</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/geoaccessor-from-df/m-p/1133646#M7003</link>
      <description>&lt;P&gt;Thanks for your response!&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the first approach but still got the same error.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PenelopeMitchell_0-1642111956366.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/31471iEE58607AB3869C0C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PenelopeMitchell_0-1642111956366.png" alt="PenelopeMitchell_0-1642111956366.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'll try the second method, but have to do some string manipulation on the x and y coord columns and just haven't had a chance to get to it yet. I'll update my post after i give it a go.&lt;/P&gt;&lt;P&gt;Thanks again,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Penelope&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 22:25:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/geoaccessor-from-df/m-p/1133646#M7003</guid>
      <dc:creator>PenelopeMitchell</dc:creator>
      <dc:date>2022-01-13T22:25:13Z</dc:date>
    </item>
  </channel>
</rss>

