So I created a new feature service (Feature Layer Collection) into a folder. It is an empty feature service with layers and table relationships. Each layer has a geometry type. I only want points. How can I delete the line and polygon layers and tables using the ArcGIS API for python? I will continue to read documentation and if I figure it out I will post back here.
I think I can use the delete_from_definition(json_dict) method listed here arcgis.features.managers module — arcgis 1.0.1 documentation.
delete_from_definition
I just need to figure out how to use it properly...
Retrieve the item either by searching or using its unique identifier, and then use the arcgis.gis.Item.delete() method.
Reporting back:
from arcgis.features import FeatureLayerCollectionfs_url = 'URL HERE'comments = FeatureLayerCollection(fs_url, gis=gis)layers = comments.layerstables = comments.tablesfor layer in layers: print(layer)for table in tables: print(table)
from arcgis.features import FeatureLayerCollectionfs_url = 'URL HERE'comments = FeatureLayerCollection(fs_url, gis=gis)
layers = comments.layerstables = comments.tablesfor layer in layers: print(layer)for table in tables: print(table)
Output will return each layer and table object.
Tried
del layers[1]
but object does not support item deletion.
I will try this next! Thanks Joshua!
This makes sense for deleting the feature service completely, but as for deleting its layers or tables it doesn't make sense to me. I can access the object (see comment below this one) but if I use the delete method on the object I get
AttributeError: 'FeatureLayer' object has no attribute 'delete'
If I ask for the object's id I get 1, which is local to the feature service itself.
I guess what I mean by feature service is that it's a feature layer collection.
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.