Simple feature layer overwrite?

982
1
08-10-2018 08:28 AM
deleted-user-OlpHy1NoMNug
Occasional Contributor II

I'm trying to overwrite a feature layer with a feature class in a local GDB, essentially just trying to script the process that takes two clicks to do within ArcGIS Pro.

I think this is how you construct the overwrite but I can't find how to choose which layer you're overwriting.


variable name that corresponds with feature layer
.manager.overwrite('path to local data')

Do I have to search for feature layer first using something like this?

search_result
= gis.content.search(query='title:test', item_type='Feature Layer Collection')
flc=FeatureLayerCollection.fromitem(search_result[0])

What's difference between Feature Layer and Feature Layer Collection?  Instead of searching can I just identify the feature layer by item id?

Scott
0 Kudos
1 Reply
MunachisoOgbuchiekwe
New Contributor III

Hello Scott,

It is my understanding that a feature layer collection is just a collection of feature layers and tables. You can access a feature layer through the id or using the URL associated with it. The following documentation (Using Feature Layers | ArcGIS for Developers ) does a good job of explaining this workflow. 

In regards to overwriting a layer you will need to make sure that the local GDB has the same schema as the layer. Then you would just do the following....

  1. Grab the feature layer you want to overwrite either through id or URL. 
  2. This should give you back a feature layer collection. You can access the individual layers by using the "layers" attribute. 
  3. Then call the overwrite method which is accessed using the manager property. 

The steps above is explained in the following sample (overwriting_feature_layers | ArcGIS for Developers). The sample is using a CSV but you can easily omit the parts you don't need since you are using a local GDB.

0 Kudos