Select to view content in your preferred language

Seperate layers from web feauture service into portal items

2330
6
02-07-2020 02:20 AM
DavidMcDermott1
Occasional Contributor

Hello,

Currently I publish web feature service which contain all the related layers. This creates an single item in portal which lists all the layers and their service URL. I would now like to seperate these layers out into their own items in portal. Is there a way to do with automatically or does it have to be done manually? The reason I am asking is this method simplifies publishing, looks neater in the legend (Until group layers are available) and enables these to documented and searchable. 

Thank you,

David 

0 Kudos
6 Replies
AndrewWhitman1
Esri Contributor

Greetings David, 

As far as I can tell based on the documentation, there is no way to separate layers once published up to Portal for ArcGIS. This is a decision that needs to be made before publishing. 

If you feel like this is a gap in functionality that could benefit a wide swath of users, I would encourage you to create an idea within ArcGIS Ideas

I did find some best practice recommendations on managing layers within Portal for ArcGIS. 

https://enterprise.arcgis.com/en/portal/latest/use/best-practices-layers.htm

I get the sense that if we are given the option to group layers together, then we would also be given the option to "ungroup" those same layers. So perhaps the request for group layers is actually what you are asking for here? If so, it has been listed as "In Product Plan" for now

Hope this helps, 

Andrew W. 

0 Kudos
DavidMcDermott1
Occasional Contributor

Hi Andrew Whitman‌,

I found this in an FAQ while I was scouring Google which is what I am aiming for:

How do I save an individual feature layer as an item?

To save an individual feature layer from a multilayer feature layer, complete the following steps:

  1. Open the item page of the multilayer feature layer and go to the Visualization tab.
  2. Choose the layer you want to save from the Layer drop-down menu.
  3. Click Save as new layer to save a copy of the layer as a new item in My Content.
  4. Type a title, tags, and a summary, and optionally choose a different folder to save the layer.
  5. Select to create the new item with Just the current layer and click Save.

This is a manual process though and I was hoping there would be an option at the point of publishing to create seperate items from multilayer map/feature layers. If not then a option in portal or even a python script. I can add that to the ideas pages as you suggested. 

Grouping layer in the portal Map Viewer has been a long time coming. The link you posted is 6 years old. Publising a multilayer map/feature services creates "groups" in a sence which improves the user expereince  but you lose the discoverability of these layer in portal. This is the basis for my question. 

0 Kudos
jill_es
Esri Contributor

Hi David - the process you describe has to be done manually.  There isn't an option for creating separate items when publishing or a python script from Esri (though perhaps somebody else here on GeoNet has one they've already written?).  With this in mind, per Andrew's comment, I would recommend adding the suggestion to the Ideas Site.

AndrewWhitman1
Esri Contributor

HI David McDermott check out Uri's script, will this help with what you are working on? 

In the meantime, this sounds like a great opportunity to capture this functionality in an Idea on the ArcGIS Ideas page. If you post the link here, others will be able to upvote it. 

Maybe a future release will feature your idea.  

UriGilad_EsriAu
Esri Contributor

Hi David, 

I wrote a simple script (and a toolbox in the reply below. Modified from CreateWebLayerSDDraft—ArcPy | Documentation) that creates separate hosted feature layers on an AGOL/Poral account. The script py file is attached to this post.

  • The script lists all layers in an ArcGIS Pro project (aprx), and then publishes each layer (which is a feature class) as a separate service
  • Run this script with Python for ArcGIS Pro (e.g. v3.6.9).
  • Fill lines 4-6 with your inputs: aprx path, map name (in aprx) and workspace path.
  • Script will publish layers to your active portal/AGOL account as specified in your ArcGIS Pro.
  • sddraft and sd files are saved to a local folder (user to provide path for folder, line 6). If you rerun the script make sure to delete these files.
  • If you rerun this script make sure to delete existing service with the same name from your account.
  • The service name will be identical to the layer's name. To change the service name insert a new name in line 17 (replace the second 'lyr' with the new name).

import arcpy

#User to insert aprx file location, folder to which sddraft and sd files will be saved, and map name
aprx = arcpy.mp.ArcGISProject(r'C:\Users\...Project.aprx')
map_name = 'Map' 
workspace = r'C:\Users\...\folder'

#List layers in aprx
m = aprx.listMaps(map_name)[0]
layers = m.listLayers('*')

#For each layer, created sddraft, sd and upload to active portal/AGOL.
for lyr in layers:
    if lyr.isFeatureLayer:
        sddraft = workspace+'\\'+str(lyr)+'.sddraft'
        sd = workspace+'\\'+str(lyr)+'.sd'
        arcpy.mp.CreateWebLayerSDDraft(lyr, sddraft, lyr, 'MY_HOSTED_SERVICES', 'FEATURE_ACCESS')
        arcpy.StageService_server(sddraft, sd)
        arcpy.UploadServiceDefinition_server(sd, 'My Hosted Services')
        print (str(lyr)+': Published successfully')
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
UriGilad_EsriAu
Esri Contributor

I've wrapped the script into a toolbox to be used in ArcGIS Pro (attached). 

It's mostly straightforward - for more info see the toolbox's help and metadata sections. 

Disclaimer: this is not an official Esri tool. It is not supported or updated.

Any feedback is welcome. 

Uri