Add a layer from an item
In this tutorial you will learn how to retrieve a layer stored in ArcGIS Online when you know its Item ID. You will get the layer item using its ID and display the layer on a map.
Prerequisites
The ArcGIS API for Python tutorials use Jupyter Notebooks to execute Python code. If you are new to this environment, please see the guide to install the API and use notebooks locally.
Steps
Add the following code to model a GIS portal from the ArcGIS API for Python.
arcgis.gis
is the ArcGIS API for Python GIS model.Use dark colors for code blocks Add line. Create a variable to hold the item ID of the public dataset. Any Item hosted on ArcGIS Online has a unique item ID attribute that can be referenced. The data item for this tutorial was prepared in advance, so we retrieved the item ID from the REST endpoint of the data (visible as the id parameter in the query component of the URL in the address bar).
Use dark colors for code blocks Add line. Create an anonymous connection to ArcGIS Online to retrieve this public data.
Use dark colors for code blocks Add line. Access this data an an ArcGIS Python API
item
object.Use dark colors for code blocks Add line. Add line. Create a map and add the new layer.
Use dark colors for code blocks Add line. Add line. Add line. Set the zoom level and center point of the map.
Use dark colors for code blocks Add line. Add line.
Your map should display the locations of trailheads in the Santa Monica Mountains.