arcgis-python-api icon indicating copy to clipboard operation
arcgis-python-api copied to clipboard

Option to append data to existing table in GeoAccessor.to_featureclass method

Open crackernutter opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe. It is frustrating that I need to use arcpy or geopandas (or some other workaround) if I want to append data from a SEDF to an existing table in my enterprise geodatabase. It seems like the GeoAccessor's to_featureclass method internals create the table then insert the data. Hoping it is easy to just skip the table creation part and just insert the data alone.

GeoAccessor.to_featureclass(table, if_exists='append')

Describe the solution you'd like Would like an option in the GeoAccessor,to_featureclass method to append the data to a table if it exists.

Describe alternatives you've considered Two options if you don't want to (e.g. unnecessary and expensive) or can't recreate the feature class (e.g. if ArcGIS Server has a schema lock on it):

  1. Use GeoAccessor.to_featureclass to write the featureclass to a temporary location, and then use arcpy.Append to append the data from the temp location feature class to your database table
  2. Use GeoPandas to_postgis, which has the parameter if_exists='append'. However if you're not using postgis this might not work.

Additional context Add any other context or screenshots about the feature request here.

crackernutter avatar Sep 22 '22 15:09 crackernutter

Hello,

This has been a topic of discussion for us before but the issue arises with validating the compatibility of the fields between the existing table and the table coming in along with a few other things.

In the next release there will be the option to append but as a new layer to an existing feature service. We can look into doing the same for table if this is a suitable option for you. Or completely overwriting the table with new data. This would still ask you to take out and combine the existing table with the new table data but it would overwrite and be in the same feature service.

What do you think of one of these two options?

nanaeaubry avatar Sep 22 '22 17:09 nanaeaubry

@nanaeaubry - thanks for the response.
A couple thoughts - appending as a new layer to an existing feature service would not really be working within a user managed geodatabase, postgis or otherwise. I imagine this would go directly to datastore as a separate table, but added as a featureservice sublayer. My concern is specific to working with our own databases.

I believe the GeoAccessor.to_featureclass already already has an option to overwrite. Combining with existing data will I suppose achieve the "append" result, but I'm concerned that if the table has a schema lock on it (for instance if it is exposed to ArcGIS Server), then the overwrite will fail.

I understand the issue with field compatibility though. However it doesn't seem like an intractable problem. Especially if you leave it up to the user to ensure the fields align - just align the fields that match between the SEDF and table, and don't write anything else. This is similar to how arcpy.Append works too - if there are fields in the source not in the destination, they don't get written. If there are fields in the destination not in the source, they just have null values.

crackernutter avatar Sep 26 '22 15:09 crackernutter

@crackernutter Thanks for the feedback. We will consider the best plan of action for this and we recognize it is useful for many users. Once we have integrated something for this I will update here! (FYI: Due to timing it will more than likely not be in this upcoming release)

nanaeaubry avatar Oct 04 '22 15:10 nanaeaubry

Hello, there is a new toolbox in arcgis pro that does something similar, but to use it you need to call it through arcpy https://www.esri.com/arcgis-blog/products/arcgis-pro/analytics/upsert-your-datasets-using-the-append-tool-in-arcgis-pro-3-1/

hildermesmedeiros avatar Feb 28 '23 17:02 hildermesmedeiros

@crackernutter Hi sorry for the long waited response.

This is correct that Pro 3.1 now supports consumption of spatially enabled dataframe into their tools. Due to arcpy having support for appending the way you are describing, we recommend that you attempt to use this method. Hope this works.

We will log this enhancement request on our end but cannot provide a timeline as of now for when it will be available. We will make sure to document it in the release notes when this occurs. Thank you!

nanaeaubry avatar Apr 25 '23 16:04 nanaeaubry