Hello,
Is there a way to count records from a hosted feature class in AGOL using Python?
Thanks
Thank you @GeeteshSingh07
This is how I did it:
# Get FeatureLayerCollectionmyCollection= signInObject.GIS.content.get('#######')
# Obtain feature layer from FeatureLayerCollectionfeatureLayer = myCollection.layers[0]# Query a Feature Layer to get a Feature Setfeature_set = featureLayer.query(where="1=1")# Assign a variable to the list of features in the Feature Setfeature_list = feature_set.features# Count recordsprint(len(feature_list))
Thank you
@JoseSanchez, might be late response, but I hope, this answers your question:
from arcgis.gis import GIS gis = GIS("https://www.arcgis.com", "username", "password") # Access your feature layer item = gis.content.get("<ITEM ID>") layer = item.layers[0] result = layer.query(return_count_only=True) # Print the count of features print("Number of features:", result)
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.