Select to view content in your preferred language

Batch uploading shapefiles to ArcGIS Online

07-13-2020 07:48 AM
New Contributor III

Google, StackExchange and GeoNet have been less fruitful than I had imagined for a seemingly bread and butter task.  I currently manage data on an ArcGIS Online Group (Organizational account) and have multiple shapefiles to upload and serve.  I don't want to package them as a database - I want the individual shapefiles to be listed individually with their specific metadata, filename, etc.  My best solution is to upload shapefiles individually - let's say 5 - 30 at a time on a weekly basis.  I really want to script this and seems the ArcGIS package on Python has this functionality?  I use Python.  

I would appreciate links to any scripts, packages or python code to help me get started.  I do have access to Arc Pro as well.  Thanks.

Tags (1)
2 Replies
Esri Contributor

Hey Zachary!

After doing some research into your inquiry I found a code sample at the URL below to achieve your desired task.  

Bulk upload and publish shapefiles to ArcGIS Online · GitHub 

Let me know how that goes for you.  Additionally, I found some posts on the ArcGIS Ideas page supporting the added ability to upload multiple items at once to ArcGIS Online.  I would recommend up voting this suggestion, and as it gains more traction development may consider implementing it! 

I hope this helps! 

New Contributor III

Thanks Lukas (late response by me!!).  I briefly tried your first link awhile back but since then I was able to get going on ArcGIS Pro and easily access the Python ArcGIS API.  The SECOND link you posted includes similar code to mine below in a response by Dong-gyun Kim.  I partially cannibalized parts from this Tutorial on the ArcGIS Python API page - Accessing and managing groups | ArcGIS for Developers.  Here is what I settled on...pseudocode = 1) Prepare lists for Titles, Tags and Snippets. 2) Login to AGOL 3) Upload shapefiles (zipped):

# 1) Tags, Titles and Snippets
# Create a list for each of the three where len(list) = n shapefiles
# 1a) TITLE
zipped_dirs = ['full/path/to/', 'full/path/to/', 'full/path/to/']
# Option A - use file names for Title:  '' into 'file1' OR do this:
title = [dir[:-4] for dir in os.listdir(zipped_dirs)]
# Option B - list file names manually/custom
# title = ['wetland birds', 'wetland sasquatch', 'wetland skunk cabbage']
# 1b) TAGS
# tags get a little wierd because I make a list of lists.  I wanted multiple tags
# for each shapefile.  There are programmatic ways to make lists of lists if
# you have a bunch of shapefiles and manual creation is time consuming...  
tags = [['wetland', 'birds'], ['wetland', 'sasquatch'], ['wetland', 'skunk cabbage']]
# snippets could have separate items within the list for each shapefile as well.
# For my purposes I was find with the same for each.  
snippet = ['wetland observation data current as of 7/13/2020'] * len(title)

# 2) GIS stuff: login with credentials
zach_gis = GIS(username = '', password = 'mypassword')
print('Connected to {} as {}'.format(,
# Group object for a group.  The string of letters, numbers is from url
some_group = Group(zach_gis, 'a6384c1111111a43bfd91f5d9723912b')

# 3) AGOL Add data to Content and Groups
for idx, shp in enumerate(zipped_dirs):
    properties_dict = {'title':title[idx],
    fc_item = zach_gis.content.add(properties_dict, data = shp)
    fc_item.share(groups = 'a6384c1111111a43bfd91f5d9723912b')