{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Display a Web Scene ArcGIS DevLab\n", "\n", "This is the completed solution for the [Diplay a web scene](https://developers.arcgis.com/labs/develop/python/display-a-web-scene) ArcGIS DevLab. [ArcGIS DevLabs](https://developers.arcgis.com/labs) are short introductory tutorials to guide you through the three phases of building geospatial apps: Data, Design, Develop." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Connected to ArcGIS Online\n" ] } ], "source": [ "from arcgis.gis import GIS\n", "dev_gis = GIS(\"https://www.arcgis.com\")\n", "print(\"Connected to {}\".format(dev_gis.properties.portalName))" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[,\n", " ]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "webscene_search = dev_gis.content.search(query=\"LA Trails *\", item_type=\"Web Scene\")\n", "webscene_search" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "
\n", " \n", " \n", " \n", "
\n", "\n", "
\n", " LA Trails and Trailheads\n", " \n", "
Web Scene by esri_devlabs\n", "
Last Modified: September 28, 2017\n", "
0 comments, 238 views\n", "
\n", "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "webscene_item = webscene_search[0]\n", "webscene_item" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## To display a web scene in your notebook, query the `WebScene` object." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from arcgis.mapping import WebScene\n", "la_trails = WebScene(webscene_item)\n", "la_trails" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Challenge" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The web scene has 2 layers\n" ] } ], "source": [ "op_layers = la_trails['operationalLayers']\n", "print(\"The web scene has {} layers\".format(len(op_layers)))" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Trailheads - Trailheads\n", "\thttps://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0\n", "Trails - Trails 0\n", "\thttps://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0\n" ] } ], "source": [ "for lyr in op_layers:\n", " print(\"{}\\n\\t{}\".format(lyr['title'], lyr['url']))" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python [conda env:arcgis-pyapi]", "language": "python", "name": "conda-env-arcgis-pyapi-py" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.3" } }, "nbformat": 4, "nbformat_minor": 2 }