ArcGIS API for Python Blog

Showing results for 
Show  only  | Search instead for 
Did you mean: 

Other Boards in This Place

Latest Activity

(29 Posts)
Occasional Contributor

This Jupyter Notebook prompts the user for a layer to replace, and a layer to replace it with, then it loops through all of the web maps the user has access to and replaces the layers. Check it out, I hope it helps...

ArcGIS Online Replace Layer in a Web Map 

0 0 185
Esri Community Manager

Yes, the whole internet, in either direction, with optional analysis on the way.  What's not to like?


0 1 416
Occasional Contributor III

Data can often be provided as a Shapefile with an accompanying file containing the attribute information, or surplus attributes to compliment those in the Shapefile, such as a CSV for example. The ArcGIS API for Python provides no method to add a Shapefile and CSV together in a zipped folder, and publish as a Hosted Service containing a Feature Layer and a Table. These have to be added and published separately. This Blog post will take a published Table and add as a Table to a Feature Service containing a Feature Layer. A relationship will be created between the Feature Layer and the Table. While this can be achieved by publishing via ArcGIS Pro, here, we will use the ArcGIS API for Python only. 


15 6 3,436
Esri Contributor


Smartsheet is a dynamic workspace that empowers teams to manage projects, automate workflows, and rapidly build new solutions. Smartsheet uses spreadsheets, referred to as sheets, as the basis of everything it does, but the difference between Smartsheet and spreadsheet programs like Microsoft Excel or Google Sheets is that Smartsheet has all sorts of collaboration functionality incorporated into it.


13 5 5,037
MVP Regular Contributor

snippets to manage a web map with the ArcGIS API for Python


1 6 2,126
MVP Regular Contributor

ArcGIS API for python User.items() method says it takes dictionary from the folders property, but the folders property says it returns a list:





the folders property actually returns a list of dictionaries:

0 0 1,130
Esri Contributor

Recently I came across ESRI web course Update Real-Time Data with Python, and it walks through a tutorial on how to built what is called "feed routine". The idea is basically is to read latest version of certain feature-set from a JSON file shared and accessed through a URL, and feed that into your system, which in this case is a hosted feature layer. 

In this blog, I wanted to focus on the function "deployLogic" which takes places after reading the latest JSON data and converting it to ESRI file-geodatabase. This function demonstrate really important workflow on how to update the data of hosted feature layer, while keeping the hosted layer item id - as a Portal for ArcGIS or AGOL item. I didn't find similar workflow explained in the published documentation for ArcPy or API for Python, and I believe it can be accommodated to be used with more complex scenarios.

I will try to summarize the function logic in the following bullets:

  • Using 7zip sub-process, extract the hosted layer service definition file
  • Browse to the extracted folder, reach the underlying source file gdb, and delete it
  • Copy the fresh file-geodatabase that was created in previous step to the extracted service definition folder
  • Using 7zip, compress the service definition folder into a new service definition file with '.sd' extension, not '.zip'
  • Using "FeatureLayerCollectionManager" instance, update the hosted layer using the new service definition file

The simplicity of this workflow is that it avoids republishing the service using ArcGIS Pro project, so you won't need to go through something like "getWebLayerSharingDraft" from a Map object, and worry about setting the needed flags "overwriteExistingService", etc.. I find this really easy shortcut, and it will get the job done.

Update Real-Time Data with Python

Update Real-Time Data with Python

Update Real-Time Data with Python

6 2 2,020
by Anonymous User
Not applicable

Happy Halloween! The ArcGIS API for Python has just released its newest version, 1.7.0. View the release notes here to see what's new and what bugs have been fixed. Visit our landing page for all other information about the Python API.

You can install this newest version via conda:

conda install -c esri arcgis

or pip:

pip install arcgis

We can't wait to hear what you think of this release!

4 10 4,731
New Contributor III

We create tile packages for field workers fairly frequently so they can have additional maps available to them when they go offline in the field.  Typically this process has involved several different tools depending on the particular map or imagery that is needing to be tiled.  Generally, I have found the ManageTileCache and ExportTileCache GP tools to be most reliable.  So recently I started thinking about combining them along with the Python API so we could have one tool to use for publishing TPK's to our AGOL Org. Any feedback or suggestions would be greatly appreciated.

Basic outline of what the tool does:

  1. Make connection and get a token from your portal with whatever credentials are being used in Pro
  2. Take an input raster dataset
  3. Create a new folder for outputs in the same directory as the input dataset
  4. Allow user to name output dataset
  5. Run ManageTileCache tool to create a local tile cache ( by default the entire extent of the input dataset is used and LOD's are created based off of the input data source pixel information)
  6. Run ExportTileCache tool to create local tpk file
  7. Report file size info back via arcpy Messages
  8. Add tpk item to portal
  9. Attempt to publish the tpk as hosted tile layer
    • Publishing a tpk item seemed to need the additional step of making a POST via the REST api to actually unpack and publish the tiles using '/updateTiles' contained in the tpk  this is done using just simply using publish() with the python api tended to fail at going beyond creating the hosted tile layer.
  10. Uses urllib to get additional info about the hosted tile layer and LOD's being published.

This tool has been handy in certain situations for us and I hope it is for someone else too.  Still I am always interested if someone has a better way of doing this.

2 0 2,500
Occasional Contributor II

For anyone interested in GIS development and Python I've put together a tutorial on using esri's ArcGIS Python API in Jupyter Notebooks.

ArcGIS Python API in Jupyter Notebooks | burdGIS - YouTube 

#gis #python #esri #arcgis #tutorial #jupyter

3 0 1,247
193 Subscribers