Select to view content in your preferred language

Converting Pandas Dataframe (with polygon geometry) to Spatially Enabled Dataframe

166
2
Jump to solution
a week ago
Labels (1)
KevinBoes1
New Contributor

I have recently run the Time Series Cross Correlation geoprocessing tool to get outputs including a polygon feature class and a correlation table listing correlation coefficients for each polygon for each lag value defined by the correlation analysis. I am hoping to take this correlation table and convert it to a polygon feature class so that I can range-enable it and create an animation showing how each polygon's correlation coefficient changes over the lag value range.

In past projects, I converted tabular data to a point feature class by reading the tabular data into a pandas dataframe, converting that dataframe to a spatially enabled dataframe using the ArcGIS API for Python geoaccessor, and converting the spatially enabled dataframe to a point feature class. In this case, though, I want to convert my tabular data into a feature class with polygon geometry. I tried adding a column to my pandas dataframe with the polygon geometry obtained from the shape@ token using arcpy.da.SearchCursor() and using Geoaccessor.from_df() to specify this column as the dataframe's geometry information, but the function appears to have timed out without completing.

Is there a different function in the Geoaccessor module that I should be using instead, or is there perhaps a different workflow for applying polygon geometry to tabular data that would be better for me to use?

0 Kudos
1 Solution

Accepted Solutions
Clubdebambos
MVP Regular Contributor

Hi @KevinBoes1,

If your goal here is to create a Polygon Feature Class you can do that with ArcPy (Create Feature Class) using your Correlation Table as a Template. Append in the Correlation table data, this will leave you without geometry which you can then grab from the original polygons. If you have a matching ID from the table back to the Polygon datasets you can iterate over the Polygon dataset with a SearchCursor and use an UpdateCursor to update the Polygon geometry.

  1. Create Templated Polygon Feature Class (you could do this in memory and only save out at the end with ExportFeatures)
  2. Append in tabular data
  3. Iterate over the Polygon dataset with a SearchCursor, update the geom using an UpdateCursor where the unique id matches.

All the best,

Glen

 

~ learn.finaldraftmapping.com

View solution in original post

0 Kudos
2 Replies
Clubdebambos
MVP Regular Contributor

Hi @KevinBoes1,

If your goal here is to create a Polygon Feature Class you can do that with ArcPy (Create Feature Class) using your Correlation Table as a Template. Append in the Correlation table data, this will leave you without geometry which you can then grab from the original polygons. If you have a matching ID from the table back to the Polygon datasets you can iterate over the Polygon dataset with a SearchCursor and use an UpdateCursor to update the Polygon geometry.

  1. Create Templated Polygon Feature Class (you could do this in memory and only save out at the end with ExportFeatures)
  2. Append in tabular data
  3. Iterate over the Polygon dataset with a SearchCursor, update the geom using an UpdateCursor where the unique id matches.

All the best,

Glen

 

~ learn.finaldraftmapping.com
0 Kudos
KevinBoes1
New Contributor

Glen,

This got me exactly what I wanted! Thank you!

0 Kudos