Skip to main content

Publishing your maps to ArcGIS Online – Daily

If you have created a map in ArcGIS Pro, you may want to share it by publishing it through ArcGIS Online as a hosted service. As you make changes to your map, it can get time consuming repackaging and uploading your new map, especially if you have daily updates and want your published map to be up-to-date.

In this blog post, I’ll show you a quick script you can write in Python that will take care of this work for you and will get you started in Jupyter Notebooks if you’ve never tried using it before. Once you’re finished the script, you can set it up to execute automatically on your computer, and your hosted service will always be current with the map that you’ve created in Pro.

To get started, you’ll need to install Jupyter Notebooks using ArcGIS Pro. Jupyter Notebooks is a Python editor that works in your web browser. It’s very good for messing around with simple Python scripts and trying out the ArcGIS API for Python. There is a good resource for installing Jupyter Notebooks here.

You’ll also need an ArcGIS Pro project that you are ready to publish. The coordinate reference system needs to be WGS1984 Web Mercator Auxiliary Sphere. Also, make sure you don’t have any basemaps in your map because the script won’t work if you do. Update all of the meta data for the project and map, including a description and tags.

Open up Jupyter notebooks by opening your start menu and navigating to ‘ArcGIS → ArcGIS Pro → Jupyter Notebooks’.

You’ll get a black window with some text opening up, and you can just ignore that. Your web browser will launch and go to ‘localhost:8888/tree’, and you should see your ‘C:\Users\<windows username>’ directory.

Make a new folder by clicking ‘New’ in the top right corner and create a place for your notebooks.

Create a new notebook by clicking ‘New’ and clicking ‘Python 3’ under ‘Notebook’. Paste the following into it. Make sure to read the comments (lines that start with #) and follow the instructions about changing the text.

import arcpy from arcgis.gis import GIS # replace the text within the quotes with the location of your ArcGIS Pro project file that you want to publish p ='c:\users\\notebooks\publish\vtpk\Parcels.aprx') # replace the text within the quotes with a location for the vector tile package you’ll create vtpk = r'c:\users\\notebooks\publish\vtpk\Parcels.vtpk' if arcpy.Exists(vtpk): arcpy.Delete_management(vtpk) # replace the text within the quotes with the name of your map in the project file for m in p.listMaps(): if == 'Barrie Buildings': my_map = m arcpy.CreateVectorTilePackage_management(my_map,vtpk,'ONLINE') # this is your arcgis online login. You’ll need to put in the url for your portal, your username and password portal_conn = GIS('', 'username', 'password') # change the text below to add a title and tags for your hosted map title = 'Ontario Parcels' tags = 'Ontario Parcels' properties = {'title':title,'type':'Vector Tile Package','tags':tags} content = for item in content: if item['title'] == title: portal_conn.content.get( # you can change the text in the folder option below to save your hosted service somewhere. # THE FOLDER MUST ALREADY EXIST vtpk_item = portal_conn.content.add(properties, data=vtpk, folder='CHANGE_ME_TO_AN_EXISTING_FOLDER_IN_YOUR_AGOL!') vtpk_layer = vtpk_item.publish() vtpk_layer

Click in the top bar. After a few minutes, you should see a thumbnail of your map appear below your script. This means your map should be available in your ArcGIS Online content, and you can share it. After you’ve made changes to your map in Pro, hit ‘run’ again, and the changes will be reflected in ArcGIS Online.

If you’re ready to automate the execution of this code, go to ‘File → Download As → Python’, and you’ll get a .py file that you can save to your computer. It doesn’t matter where.

Now open up your Start Menu and search for ‘Task Scheduler’. Click ‘Create Task’ on the right side, and you’ll get a pop up. Enter the following details

  1. On the General tab, give it a name and description like ‘Daily update for my ArcGIS Online Map’.
  2. On the ‘Triggers’ tab, click ‘New’. This is where you indicate when the code should execute. Try a daily start at 9 am. Something that makes sense for when your computer will be on.
  3. On the ‘Actions’ tab, click ‘New’.
    • Action is ‘Start a Program’
    • Program/Script is ‘c:\users\<your username>\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe’ (verify that this is actually where your Pro python exe is by checking the path for Project Environment in your Python settings in Pro).
    • Under Add Arguments, put in the location of your .py file that you downloaded.

You’re all set. Tomorrow morning, check that your code executed by looking at the modified date for the service in ArcGIS Online.

About the Author

Justin Pierre is a Software Developer in the Technology Strategy Department of Esri Canada. His main project is the GeoFoundation Exchange or GFX – a data repository and data exchange platform for managing source geographic basemap data. He has a Masters in Spatial Analytics from Ryerson University and has 10 years of experience in GIS Analytics and Development across a number of fields including agriculture, real estate and retail. Justin loves travelling, especially south, for some diving.

Profile Photo of Justin Pierre