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}'.")
Solved! Go to Solution.
You'll want to convert your feature service item to a FeatureLayerCollection, from there you can get the properties and check "hasViews" or "isView".
You'll want to convert your feature service item to a FeatureLayerCollection, from there you can get the properties and check "hasViews" or "isView".
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.