Good morning,
I am looking for a way to select all hosted feature classes that belong to a specific group
items = gis.content.search(query='')
You can do this at least two ways:
Like this:
group_id = "1234_your_group_id_5678" gis.content.search(query=f"group: {group_id}", item_type="Feature Service")
or like this:
group_id = "1234_your_group_id_5678" group = gis.groups.get(group_id) group.search(query="type:Feature Service")
Thank you @EarlMedina
This is what I wrote and it works:
# Retrieve Group IDgroup = GIS.groups.get(group_id)print (group)# List all feature layers collections in the groupfeature_layer_collections = []for item in group.content():## print (item)## print (item.type)## print (item.id)# Filter for feature layer itemsif item.type == "Feature Service":#Get the Feature Layer Collectionflc = FeatureLayerCollection.fromitem(item)feature_layer_collections.append(flc)#print ("Append")# Create a unique export title based on the item name and timestamp# Create a datetime objectnow = datetime.datetime.now()formatted_date = now.strftime("%Y%m%d_%H:%M:%S")## export_title = f"{item.title}_backup_{formatted_date}"export_title = f"{formatted_date}_backup_{item.title}"
# Export the item to File Geodatabase formatprint(f"Exporting {item.title}...")export_item = item.export(title=export_title, export_format="File Geodatabase",parameters=None,wait=True)# Download the exported file to the backup directoryexport_path = os.path.join(backup_directory, f"{export_title}.zip")export_item.download(backup_directory)# Clean up the export item from ArcGIS Onlineexport_item.delete()
@SanchezNuñez Wanted to say thank you for this gem. This is exactly what I have been working on to help staff manage there data from various field project in AGOL. Thank you!
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.