Select to view content in your preferred language

Selecting one layer from a feature layer collection

426
1
Jump to solution
08-15-2018 10:12 AM
KonradHughes
Emerging Contributor

I have a feature layer collection with 3 layers, and I only want to perform analysis on one of the 3 layers.  What is the method for assigning only that one layer of interest to a variable that I can perform analysis on?  Thanks

0 Kudos
1 Solution

Accepted Solutions
MunachisoOgbuchiekwe
Regular Contributor

Hello Konrad, 

Something like this would work.....

import arcgis
from arcgis.gis import GIS

gis = GIS()

# Grab the feature layer item by id
featureLayerItem = gis.content.get('c7c2420dfa884f34890da0a78b6a0533')
#Print out layer 0 from the layer list
print(featureLayerItem.layers[0])‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Essentially, you can call the "layers" property which gives you back a list. Then you can access an item from that list by using the square bracket notation. 

View solution in original post

0 Kudos
1 Reply
MunachisoOgbuchiekwe
Regular Contributor

Hello Konrad, 

Something like this would work.....

import arcgis
from arcgis.gis import GIS

gis = GIS()

# Grab the feature layer item by id
featureLayerItem = gis.content.get('c7c2420dfa884f34890da0a78b6a0533')
#Print out layer 0 from the layer list
print(featureLayerItem.layers[0])‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Essentially, you can call the "layers" property which gives you back a list. Then you can access an item from that list by using the square bracket notation. 

0 Kudos