Select to view content in your preferred language

Filter View Layers

728
2
Jump to solution
11-13-2023 05:07 AM
Labels (1)
gargarcia
Occasional Contributor

I am trying to find my AGOL hosted feature layers that are not view layers. In my code I first identify how many items are in a content folder, then I filter out only feature services. This will include both parent layers and their view layers. I can't figure out how to just get the parent layers. I thought there was a property for "has views" but I haven't been able to figure out how to use that either. Is it possible to find just the parent hosted feature layers from my content or just the view layers?

# Get the user's folder
user = gis.users.me
folder_name = "Data"

# Get list of items from the folder
items = user.items(folder=folder_name)
print(f"Found {len(items)} items in the folder '{folder_name}'.")

# Filter to get only feature services
FeatureServices = [item for item in items if item.type == "Feature Service"]
print(f"Found {len(FeatureServices)} feature services in the folder '{folder_name}'.")

 

0 Kudos
1 Solution

Accepted Solutions
MobiusSnake
MVP Regular Contributor

You'll want to convert your feature service item to a FeatureLayerCollection, from there you can get the properties and check "hasViews" or "isView".

View solution in original post

2 Replies
MobiusSnake
MVP Regular Contributor

You'll want to convert your feature service item to a FeatureLayerCollection, from there you can get the properties and check "hasViews" or "isView".

gargarcia
Occasional Contributor

Thanks, that was it. I did get hung up for a minute because it appears that if either of those properties is false, instead of just saying false the property is not present.

0 Kudos