In my ArcGIS API for Python script I need to search for Feature Services, but need to exclude some of these from my query (or if necessary, ignore them in the results of the query) based on a few criteria. I've been able to exclude views as:
agol_feature_services = gis.content.search(query=f"NOT typekeywords:View Service", max_items=10000, item_type="Feature Service")
However, I also need to exclude Oriented Imagery Layers (OILs). Is there any way to query a Feature Service item to determine if it is for an OIL?
If I can't include this in the query (as above), can I do it later when I loop through the query results like below?
for fs_item in agol_feature_services:
Using a public layer as an example, you can find that the sub-layer inside a given collection (item) is typed with 'Oriented Imagery Layer'. Using this you can write a function that would handle collecting only items from your search that do not have layers of this type. That would look something like:
def remove_oil(items: list) -> list:
result = []
for item in items:
types = []
for layer in item.layers:
types.extend([layer.properties.type])
print(f"{layer.properties.name} contains {types}")
if 'Oriented Imagery Layer' not in types:
result.append(item)
return result