I have a folder on ArcGIS Online for a city that has few layers in it. I need to create separate folders for each city and then create new feature layers using these existing layers, preferably using Python script. I'm stuck right as I don't know how to create new feature layer from existing layer using Python (also, this new layer shouldn't be linked to the existing layer. The configuration should be exact same with only difference that they should have separate id's).

from arcgis.gis import GIS

gis = GIS("https://www.arcgis.com", username, password)
# Log into ArcGIS Online
gis = GIS('home')

#Town input from user
town_name = input('Enter town name: ')
town_abr = input('Enter town initials/Site id: ')

#creating town folder

search_result = gis.content.search(query="title:STR_ENK1_COL_Duct Route Existing", item_type="Feature Layer")

existing_layer = gis.content.get('f21d1f7edbce478e88782e5a29728c11')

1 Answer 1


existing_layer = gis.content.get('f21d1f7edbce478e88782e5a29728c11')
derived_copy_layer = existing_layer.copy()

The copy method allows for the creation of an item that is derived from the current Item.For layers, copy will create a new item that uses the URL as a reference. For non-layer based items, these will be copied and the exact same data will be provided.

existing_layer = gis.content.get('f21d1f7edbce478e88782e5a29728c11')
independent_copy_layer = existing_layer.copy_item()

The copy_item operation creates a new Item that is a copy of the original Item on the server-side. It is quite similar to the copy method but only creates a new Item. But there is a caveat, hosted services are copied as reference only.

As your items are hosted feature layers, so create a reference-based copy and then filter your features for each copied item.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.