Is it possible to create a deepcopy from a feature class?

960
1
01-08-2019 01:05 AM
HugoBouckaert1
New Contributor III

Hi 

At the moment I have a python script to insert, update or delete features from a feature layer. This works well, but I have to upload the feature class containing the new records first to AGOL and publish it as a feature layer. This is because in order to update an existing feature layer, I have to create a deepcopy from the layer containing the new records, like so:

Say my layer (with the new records) is named "updater_layer". I do a query on it, using a where clause :

updater_layer_query = updater_layer.query(where=where_clause)

# I get the features: 

update_query_features = updater_layer_query.features

# and create a deepcopy which I can use to update an existing layer
new_features = deepcopy(update_query_features)

 

But to get those deepcopy records, I first have to upload and publish a new layer with new records to AGOL. 

I am wondering if there is a way to do this on the desktop so that I end up with a deepcopy list from the feature class on the desktop, without having to upload the feature class first to AGOL as a feature layer. That deepcopy (derived from the feature class on the desktop) can then directly be used to update an existing feature layer in AGOL.

I looked but it does not seem possible to create a deepcopy from a feature class. Is there a way to do this, perhaps via a JSON representation of the feature class or perhaps by using a searchcursor on the feature class?   

Thanks

Hugo 

0 Kudos
1 Reply
by Anonymous User
Not applicable

I found this ArcGIS API for Python sample notebook useful: updating_features_in_a_feature_layer | ArcGIS for Developers ; deepcopy from a AGOL feature layer is demonstrated.