Converting Pandas Dataframe to GIS Table in_memory Fails with arcgis.features.GeoAccessor.spatial.to_table()

3272
4
Jump to solution
05-04-2021 10:54 AM
Justin_P
New Contributor III

Hi, I am using the GeoAccessor module inside arcgis.features to enable spatial features in pandas dataframes to process some data as part of a python toolbox tool. I was able to convert a database table to a pandas dataframe and perform all the necessary data manipulation, but when I try to bring it back into a GIS table in_memory it doesn't seem to work.

# Convert my pandas dataframe 'sdf_table' to a GIS database table in_memory
processed_table = sdf_table.spatial.to_table('in_memory/processed_table')
...
# After additional processing, copy this table to the user specified output database table
output_table = arcpy.CopyFeatures_management(processed_table, output_table)

This code fails on the Copy Features function, saying that the in_memory table does not exist or is not supported. It DOES work if I skip the in_memory output and just output directly to the final database location in the to_table() method. This leads me to believe that the arcgis.features.GeoAccessor.spatial.to_table() method does not support in_memory output, but I can't find any documentation saying that. Can anyone confirm this? I find it strange that there are no errors or warnings if the output path is not supported.

File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 3886, in CopyFeatures
retval = convertArcObjectToPythonObject(gp.CopyFeatures_management(*gp_fixargs((in_features, out_feature_class, config_keyword, spatial_grid_1, spatial_grid_2, spatial_grid_3), True)))
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 511, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Features: Dataset in_memory\processed_table does not exist or is not supported

 

0 Kudos
1 Solution

Accepted Solutions
Justin_P
New Contributor III

Just for the record, this was a silly mistake that had nothing to do with in_memory. I was using Copy Features when I should have been using Copy Rows since the output is strictly tabular.

View solution in original post

0 Kudos
4 Replies
DavidPike
MVP Frequent Contributor

how about 

r'memory\processed_table'
0 Kudos
Justin_P
New Contributor III

I did have a little bit of hope with this, but unfortunately it appears that it doesn't like the 'memory' workspace either and fails with the same error when I try to access it with the next function.

Justin_P
New Contributor III

Just for the record, this was a silly mistake that had nothing to do with in_memory. I was using Copy Features when I should have been using Copy Rows since the output is strictly tabular.

0 Kudos
alex_friant
Occasional Contributor II

For those who are still having problems with this method, it's filed as a BUG "In Review":
https://support.esri.com/en-us/bug/there-is-a-bug-in-the-spatial-dataframe-option-totable-bug-000154...

0 Kudos