You will learn: how to use the ArcGIS API for Python to load a web scene for display.

An ArcGIS web scene is a display of geographic information that allows you to visualize and analyze geographic information in an intuitive and interactive 3D environment. Visit the product documentation for web scenes to get a complete overview.

In this lab you will search ArcGIS Online for an existing web scene and display it using the ArcGIS API for Python.


Display a web scene with the ArcGIS API for Python

  1. Go to the Esri Juptyter 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.

  2. Add the following code in a cell to import the ArcGIS API for Python.

    from arcgis.gis import *
  3. Make an anonymous connection to ArcGIS Online.

    dev_gis = GIS("https://www.arcgis.com")
  4. Search for a publicly available web scene owned by esri_devlabs containing datasets about Los Angeles, CA trails. You'll use the wildcard capabilities of the search engine to narrow the search.

    webscene_search = dev_gis.content.search(query = "LA Trails *", item_type = "Web Scene")
  5. Retrieve the web scene item from the resulting list.

    webscene_item = webscene_search[0]
  6. Import the WebScene class from the arcgis.mapping module and visualize the web scene.

    from arcgis.mapping import WebScene
    la_trails = WebScene(webscene_item)

Congratulations, you're done!

Your scene and layers (feature services) should look something like this.


Explore the layers in the Web Scene with the REST API.

All hosted feature layers have a REST endpoint that you can use to access the data directly. This can be accomplished with a URL request from a web browser, a custom application, or the ArcGIS APIs.

Let's retrieve the layers from the web scene. You can query the web scene as a dictionary.

  1. op_layers = la_trails['operationalLayers']
    print("The web scene has {} layers.".format(len(op_layers)))
  2. Query the list for the title and url values of each layer.

    for lyr in op_layers:
        print("{}\n\t{}".format(lyr['title'], lyr['url']))
  3. In your browser, add the url for the Trails layer to the browser (or just copy/paste from below) to explore the REST endpoint:


  1. Explore the other layers through the same steps.

To learn more about querying data with the REST API, see the Query a feature layer lab.