Skip to content

Instantly share code, notes, and snippets.

@nommuna2
Last active April 26, 2019 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nommuna2/d5bb4b02137eef2dc7af6c4a5975f180 to your computer and use it in GitHub Desktop.
Save nommuna2/d5bb4b02137eef2dc7af6c4a5975f180 to your computer and use it in GitHub Desktop.
(ArcGIS API for Python) Delete fields from a feature layer using the python API
import arcgis
from arcgis.gis import GIS
# Provide credentials to the GIS object.
gis = GIS(username="username", password= "password")
#Get the id of the hosted feature layer
item = gis.content.get("id of feature layer")
#Get the feature layer itself
fl = item.layers[0]
#This is the JSON structure you need to pass in so that it knows what field to delete.
# https://developers.arcgis.com/rest/services-reference/delete-from-definition-feature-layer-.htm
json = {
"fields" : [
{
"name" : "POP90_SQMI"
}
]
}
result = fl.manager.delete_from_definition(json)
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment