<?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 spatially enabled dataframe problems with spatial.WKT function in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/spatially-enabled-dataframe-problems-with-spatial/m-p/1250909#M8298</link>
    <description>&lt;P&gt;Using Arcgis Pro 2.9.1, Python API 1.9.1&lt;/P&gt;&lt;P&gt;I've been trying to do some work with spatially enabled frames using the spatial (geometry) properties.&amp;nbsp; In this work I've seen that these operations are incredibly slow.&amp;nbsp; &amp;nbsp;For example a Pandas operation such as&lt;/P&gt;&lt;LI-CODE lang="c"&gt;sedf['wkt'] = sedf['SHAPE'].spatial.WKT&lt;/LI-CODE&gt;&lt;P&gt;takes over 7 hours for a approximately 700,000 row dataframe.&amp;nbsp; Other Pandas operations run in seconds.&amp;nbsp; One hypothesis is that the spatial data frame is not using vectorized operations.&lt;/P&gt;&lt;P&gt;Another issue with the WKT is returning the correct coordinate values.&lt;/P&gt;&lt;P&gt;In the graphic, the areas shown in purple is correct, the area shown in green are the values returned by the WKT property.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 482px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/61089i8849852C359BCBD2/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is after have to remove the negative '-' signs from the returned WKT values.&lt;/P&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>Tue, 24 Jan 2023 17:30:34 GMT</pubDate>
    <dc:creator>DavidAnderson_1701</dc:creator>
    <dc:date>2023-01-24T17:30:34Z</dc:date>
    <item>
      <title>spatially enabled dataframe problems with spatial.WKT function</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/spatially-enabled-dataframe-problems-with-spatial/m-p/1250909#M8298</link>
      <description>&lt;P&gt;Using Arcgis Pro 2.9.1, Python API 1.9.1&lt;/P&gt;&lt;P&gt;I've been trying to do some work with spatially enabled frames using the spatial (geometry) properties.&amp;nbsp; In this work I've seen that these operations are incredibly slow.&amp;nbsp; &amp;nbsp;For example a Pandas operation such as&lt;/P&gt;&lt;LI-CODE lang="c"&gt;sedf['wkt'] = sedf['SHAPE'].spatial.WKT&lt;/LI-CODE&gt;&lt;P&gt;takes over 7 hours for a approximately 700,000 row dataframe.&amp;nbsp; Other Pandas operations run in seconds.&amp;nbsp; One hypothesis is that the spatial data frame is not using vectorized operations.&lt;/P&gt;&lt;P&gt;Another issue with the WKT is returning the correct coordinate values.&lt;/P&gt;&lt;P&gt;In the graphic, the areas shown in purple is correct, the area shown in green are the values returned by the WKT property.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 482px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/61089i8849852C359BCBD2/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is after have to remove the negative '-' signs from the returned WKT values.&lt;/P&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>Tue, 24 Jan 2023 17:30:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/spatially-enabled-dataframe-problems-with-spatial/m-p/1250909#M8298</guid>
      <dc:creator>DavidAnderson_1701</dc:creator>
      <dc:date>2023-01-24T17:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: spatially enabled dataframe problems with spatial.WKT function</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/spatially-enabled-dataframe-problems-with-spatial/m-p/1251224#M8306</link>
      <description>&lt;P&gt;I agree the operations can be slow to work with. Building a spatial index on a large DataFrame is another example operation that can be very slow. I think the type of geometry will affect this. It looks like you have very complex polygons.&lt;/P&gt;&lt;P&gt;I don't think the GeoAccessor and GeoSeriesAccessor has changed too much, but I tried this on a shapefile with 79,000 linear features using ArcGIS Pro 3.&lt;/P&gt;&lt;P&gt;For this code it took on average 28 seconds to run:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;%timeit sedf.SHAPE.geom.WKT

28.1 s ± 1.23 s per loop (mean ± std. dev. of 7 runs, 1 loop each)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It took a little less time using Pandas' apply function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;%timeit sdf[~pd.isnull(sdf["SHAPE"])]["SHAPE"].apply(lambda x: x.WKT)

22.1 s ± 956 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; I don't have the flipped problem with the test data I used. It could be something to do with the Spatial Reference System that is assigned to the dataframe? Again, polygons are more complex with the ordering of the points signaling if it is an inside ring or the main ring. You might report this as a potential bug.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2023 12:53:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/spatially-enabled-dataframe-problems-with-spatial/m-p/1251224#M8306</guid>
      <dc:creator>dslamb2022</dc:creator>
      <dc:date>2023-01-25T12:53:02Z</dc:date>
    </item>
  </channel>
</rss>

