Select to view content in your preferred language

Duplicate AGO Hosted View Layers

625
2
Jump to solution
05-12-2023 09:35 AM
JohnStreeb
Occasional Contributor

I've published Feature layer (hosted) to ArcGIS Online from ArcGIS Pro (3.1.1).  The feature layer contains a number of individual data layers for a large region.  I'd like to create individual Feature layer (hosted, view) for some of the layers for each individual county within the region where the data is queried by county name.  What I'm hoping is that someone can help me with a more efficient workflow than manually creating these view layers for each individual county.  All of the view layers will end up being the same except in the attribute filter on the view layer the county name will be different.

I've seen in the ArcGIS Python API that you can copy various items from one organization to another for staging/production migrations and such, but I've not seen anything specifically for doing what I'm talking about with duplicating a view layer within an organization that keeps a reference to the same source hosted layer.  I may just have been using the wrong search terms though.  I'm ok manually updating the specific county name in the attribute queries if I need to, but I'd prefer to not have to manually duplicate the entire process including field settings, description, and other view layer customizations for every county if someone has an alternative.  

Any suggestions would be appreciated.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JohnStreeb
Occasional Contributor

Thank you for the information.  This helped me get on the right track of knowing what I'm looking for and where to look.

And as a note for anyone else who may stumble across this, Josh Carlson's post helped me then find the post https://community.esri.com/t5/arcgis-api-for-python-blog/using-the-arcgis-api-for-python-to-create-a... which ended up getting me what is a starting point for the solution I'm likely to end up using for this (essentially, creating the view layers from the ArcGIS Python API directly instead of trying to manually create the first one in the UI and then find a way to copy and alter the view layers).

View solution in original post

0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

When you create a new view from the Portal interface, your browser sends a POST request to your-portal/sharing/rest/content/users/your-username/createService

Read more about it here: https://developers.arcgis.com/rest/users-groups-and-items/create-service.htm

In the Python API, this is arcgis.gis.ContentManager.create_empty_service, described in the docs:

Creates a blank or view based service.

Once created, a second POST is sent to your-server/rest/admin/services/Hosted/new-service-name/FeatureServer/addToDefinition

This request includes all the information about fields, etc., as well as the name of the source service.

In the Python API, you can do this using arcgis.features.managers.FeatureLayerManager.add_to_definition

It would probably be a bit complex to set up initially, but then a very simple matter to iterate over a list of county names to get all your views created.

- Josh Carlson
Kendall County GIS
JohnStreeb
Occasional Contributor

Thank you for the information.  This helped me get on the right track of knowing what I'm looking for and where to look.

And as a note for anyone else who may stumble across this, Josh Carlson's post helped me then find the post https://community.esri.com/t5/arcgis-api-for-python-blog/using-the-arcgis-api-for-python-to-create-a... which ended up getting me what is a starting point for the solution I'm likely to end up using for this (essentially, creating the view layers from the ArcGIS Python API directly instead of trying to manually create the first one in the UI and then find a way to copy and alter the view layers).

0 Kudos