AnsweredAssumed Answered

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

Question asked by H.Bouckaert_westernpower on Jan 8, 2019
Latest reply on Jan 9, 2019 by ltyson

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 

Outcomes