Select to view content in your preferred language

Can the container property for a FeatureLayer move a FeatureLayer to another Hosted Feature Service?

06-14-2024 10:25 AM
Labels (2)
Occasional Contributor III

Take a look at the ArcGIS API for Python reference for the FeatureLayer and the container property here. An also shown below.



This states that you can GET or SET the FeatureLayerCollection to which the layer belongs. Since a FeatureLayerCollection represents a Feature Service, according to the documentation I should be able to use this to transfer a FeatureLayer from one Feature Service to another.

Is this actually possible with the container property or is the documentation to teasing the heck out of me? I have a feeling it is nonsense but really want it to be capable.

All the best,


0 Kudos
2 Replies
Esri Regular Contributor

A nice idea, but alas I believe the intended usage of this is something like this:


from arcgis.gis import GIS
gis = GIS("", "user", "passwd")

feature_layer_id = "123456789abcdefghijk" # here feature layer in the portal Item sense, not API object sense
item = gis.content.get(feature_layer_id )
flc = item.layers[0].container # here any layer/table index should return the same FeatureLayerCollection object


So, just another way to get a FeatureLayerCollection. There might be scenarios where this could be more convenient than using fromitem (maybe when fiddling with views?), but to me using fromitem or just directly initializing a FeatureLayerCollection is more readable.


Regarding the get/set - that's just Python. Everything is public so you're allowed to set things you probably wouldn't or shouldn't set 🙂


Occasional Contributor III

Thanks @EarlMedina 

I had a feeling that was the case. I was hoping for some behind the scenes Esri magic when you set the container property, I got excited but I'm back down to Earth now 😅 



0 Kudos