Last active
April 26, 2019 21:01
-
-
Save nommuna2/ce5296e30b01caf62f748f79d3df01ba to your computer and use it in GitHub Desktop.
(ArcGIS API for Python) Sample of downloading feature services from AGOL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import arcgis | |
import json | |
from arcgis.gis import GIS | |
gis = GIS(None,'username', 'password', verify_cert=False) | |
# Download all data from a user | |
def downloadUserItems(owner, downloadFormat): | |
try: | |
#Search items by username | |
items = gis.content.search('owner:{0}'.format(owner)) | |
print(items) | |
#Loop through each item and if equal to Feature service then download it | |
for item in items: | |
if item.type == 'Feature Service': | |
result = item.export('sample {}'.format(item.type), downloadFormat) | |
result.download(r'file path of where to store the download') | |
except Exception as e: | |
print(e) | |
# Function takes in two parameters. Username and the type of download format | |
downloadUserItems('username', downloadFormat='Shapefile') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment