Skip to content

Instantly share code, notes, and snippets.

@nommuna2
Last active April 26, 2019 21:04
Show Gist options
  • Save nommuna2/78d1dbf9b45755636b057c8b2b010359 to your computer and use it in GitHub Desktop.
Save nommuna2/78d1dbf9b45755636b057c8b2b010359 to your computer and use it in GitHub Desktop.
(ArcGIS API for Python) Sample of exporting a Feature layer to a file GeoDatabase using Python API
import arcgis
import json
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')
params = {
'layers': [
{'id': 0, 'where': "STATE_NAME = 'Washington'"}
]
}
try:
geoDbItem = featureLayerItem.export('StatesFL4','File Geodatabase', params)
geoDbItem.download(r'path to file')
print(geoDbItem)
except Exception as e:
print(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment