You will learn: how to load a layer from an ArcGIS Online item and add it to a map.
With your ArcGIS Developer account, you can import different file formats (CSV, XLS, GPX, GeoJSON, Shapefiles, etc) to ArcGIS Online and then use them in your apps. This process is called publishing a hosted feature layer and behind every feature layer is a RESTful service that supports spatial queries and editing operations.
In this lab you will learn how to retrieve a layer stored in ArcGIS Online when you know its identifier, item id. You will get the layer item using its identifier and display the layer contents on a map.
Go to the Esri Jupyter Notebook 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.
anon_gis = GIS()
Access this dataset as an ArcGIS Python API
trailheads_itm = anon_gis.content.get(trailheads_id) trailheads_itm
Load a map of Los Angeles in your notebook at a zoom level of 8 and add the item's layer to the map.
m1 = anon_gis.map("Los Angeles, CA", 8) m1.add_layer(trailheads_itm) m1
Your layer should look something like this: Trailheads.
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 lab and search for interesting open data you could add in another layer in your app.