Skip to content

Instantly share code, notes, and snippets.

@nommuna2
Last active April 26, 2019 21:04
Show Gist options
  • Save nommuna2/ecd89f10d8e24030420a31517e698fb9 to your computer and use it in GitHub Desktop.
Save nommuna2/ecd89f10d8e24030420a31517e698fb9 to your computer and use it in GitHub Desktop.
(ArcGIS API for Python) Update service definition in AGOL
import arcgis
from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection
# Log into AGOL account [admin level]
gis = GIS(None,'username', 'password', verify_cert=False)
# Grab the feature layer item by id
featureLayerItem = gis.content.get('feature layer id')
# Get the FeatureLayer Collection from the featureLayer
flProps = FeatureLayerCollection.fromitem(featureLayerItem)
# Dcitionary of the stuff I want to change
flProps_dict = {
'layers': [
{
"id": 0,
"name": "U.S. States (Generalized)",
"parentLayerId": -1,
"defaultVisibility": False,
"subLayerIds": 'null',
"minScale": 0,
"maxScale": 0,
"geometryType": "esriGeometryPolygon"
}
]
}
#Update the definition of the service and print out if it was successful
print(flProps.manager.update_definition(flProps_dict))
print(flProps.properties.layers[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment