You will learn: how to load a layer from an ArcGIS Online item and add it to a map.
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.
Go to Esri Juptyter Notebooks and click New > Python 3 to create a new notebook.
In each step below, type (or copy and paste) the commands into a new notebook cell and run the code by clicking run cell or pressing shift + Enter.
Add the following code to model a GIS portal from the ArcGIS API for Python.
from arcgis.gis import GIS
Create a variable to hold the item ID of the public dataset.
trailheads_id = '883cedb8c9fe4524b64d47666ed234a7'
Create an anonymous connection to ArcGIS Online to retrieve this public data.
gis = GIS()
Access this dataset as an ArcGIS Python API
trailheads_item = gis.content.get(trailheads_id) trailheads_item
Create a map and add the new layer.
m = gis.map() m.add_layer(trailheads_item)
Display the map in your Juptyer notebook.
Set the zoom level and center point of the map.
m.center = [34.09042, -118.71511] # `[latitude, longitude]` m.zoom = 11
Your layer should look something like this Trailheads Feature Layer.
Search for the Parks and Open Space and Trails layers and retrieve their item id values. Use those values to obtain the item and draw each layer on a map.
If you have not already done so, visit the Discover data tutorial and search for interesting open data you could add as another layer to your map.