|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "# Display a Web Scene ArcGIS DevLab\n", |
| 8 | + "\n", |
| 9 | + "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." |
| 10 | + ] |
| 11 | + }, |
| 12 | + { |
| 13 | + "cell_type": "code", |
| 14 | + "execution_count": 2, |
| 15 | + "metadata": {}, |
| 16 | + "outputs": [ |
| 17 | + { |
| 18 | + "name": "stdout", |
| 19 | + "output_type": "stream", |
| 20 | + "text": [ |
| 21 | + "Connected to ArcGIS Online\n" |
| 22 | + ] |
| 23 | + } |
| 24 | + ], |
| 25 | + "source": [ |
| 26 | + "from arcgis.gis import GIS\n", |
| 27 | + "dev_gis = GIS(\"https://www.arcgis.com\")\n", |
| 28 | + "print(\"Connected to {}\".format(dev_gis.properties.portalName))" |
| 29 | + ] |
| 30 | + }, |
| 31 | + { |
| 32 | + "cell_type": "code", |
| 33 | + "execution_count": 3, |
| 34 | + "metadata": {}, |
| 35 | + "outputs": [ |
| 36 | + { |
| 37 | + "data": { |
| 38 | + "text/plain": [ |
| 39 | + "[<Item title:\"LA Trails and Trailheads\" type:Web Scene owner:esri_devlabs>,\n", |
| 40 | + " <Item title:\"3d trails and trailheads LA\" type:Web Scene owner:tim.lohnes_Hayward>]" |
| 41 | + ] |
| 42 | + }, |
| 43 | + "execution_count": 3, |
| 44 | + "metadata": {}, |
| 45 | + "output_type": "execute_result" |
| 46 | + } |
| 47 | + ], |
| 48 | + "source": [ |
| 49 | + "webscene_search = dev_gis.content.search(query=\"LA Trails *\", item_type=\"Web Scene\")\n", |
| 50 | + "webscene_search" |
| 51 | + ] |
| 52 | + }, |
| 53 | + { |
| 54 | + "cell_type": "code", |
| 55 | + "execution_count": 4, |
| 56 | + "metadata": {}, |
| 57 | + "outputs": [ |
| 58 | + { |
| 59 | + "data": { |
| 60 | + "text/html": [ |
| 61 | + "<div class=\"item_container\" style=\"height: auto; overflow: hidden; border: 1px solid #cfcfcf; border-radius: 2px; background: #f6fafa; line-height: 1.21429em; padding: 10px;\">\n", |
| 62 | + " <div class=\"item_left\" style=\"width: 210px; float: left;\">\n", |
| 63 | + " <a href='https://www.arcgis.com/home/item.html?id=1da0ba4b0f674286875e58ec397260f1' target='_blank'>\n", |
| 64 | + " <img src='https://www.arcgis.com/sharing/rest//content/items/1da0ba4b0f674286875e58ec397260f1/info/thumbnail/thumbnail.jpeg' class=\"itemThumbnail\">\n", |
| 65 | + " </a>\n", |
| 66 | + " </div>\n", |
| 67 | + "\n", |
| 68 | + " <div class=\"item_right\" style=\"float: none; width: auto; overflow: hidden;\">\n", |
| 69 | + " <a href='https://www.arcgis.com/home/item.html?id=1da0ba4b0f674286875e58ec397260f1' target='_blank'><b>LA Trails and Trailheads</b>\n", |
| 70 | + " </a>\n", |
| 71 | + " <br/><img src='https://www.arcgis.com/home/js/jsapi/esri/css/images/item_type_icons/websceneglobal16.png' style=\"vertical-align:middle;\">Web Scene by esri_devlabs\n", |
| 72 | + " <br/>Last Modified: September 28, 2017\n", |
| 73 | + " <br/>0 comments, 238 views\n", |
| 74 | + " </div>\n", |
| 75 | + " </div>\n", |
| 76 | + " " |
| 77 | + ], |
| 78 | + "text/plain": [ |
| 79 | + "<Item title:\"LA Trails and Trailheads\" type:Web Scene owner:esri_devlabs>" |
| 80 | + ] |
| 81 | + }, |
| 82 | + "execution_count": 4, |
| 83 | + "metadata": {}, |
| 84 | + "output_type": "execute_result" |
| 85 | + } |
| 86 | + ], |
| 87 | + "source": [ |
| 88 | + "webscene_item = webscene_search[0]\n", |
| 89 | + "webscene_item" |
| 90 | + ] |
| 91 | + }, |
| 92 | + { |
| 93 | + "cell_type": "markdown", |
| 94 | + "metadata": {}, |
| 95 | + "source": [ |
| 96 | + "## To display a web scene in your notebook, query the `WebScene` object." |
| 97 | + ] |
| 98 | + }, |
| 99 | + { |
| 100 | + "cell_type": "code", |
| 101 | + "execution_count": null, |
| 102 | + "metadata": { |
| 103 | + "collapsed": true |
| 104 | + }, |
| 105 | + "outputs": [], |
| 106 | + "source": [ |
| 107 | + "from arcgis.mapping import WebScene\n", |
| 108 | + "la_trails = WebScene(webscene_item)\n", |
| 109 | + "la_trails" |
| 110 | + ] |
| 111 | + }, |
| 112 | + { |
| 113 | + "cell_type": "markdown", |
| 114 | + "metadata": {}, |
| 115 | + "source": [ |
| 116 | + "## Challenge" |
| 117 | + ] |
| 118 | + }, |
| 119 | + { |
| 120 | + "cell_type": "code", |
| 121 | + "execution_count": 6, |
| 122 | + "metadata": { |
| 123 | + "scrolled": true |
| 124 | + }, |
| 125 | + "outputs": [ |
| 126 | + { |
| 127 | + "name": "stdout", |
| 128 | + "output_type": "stream", |
| 129 | + "text": [ |
| 130 | + "The web scene has 2 layers\n" |
| 131 | + ] |
| 132 | + } |
| 133 | + ], |
| 134 | + "source": [ |
| 135 | + "op_layers = la_trails['operationalLayers']\n", |
| 136 | + "print(\"The web scene has {} layers\".format(len(op_layers)))" |
| 137 | + ] |
| 138 | + }, |
| 139 | + { |
| 140 | + "cell_type": "code", |
| 141 | + "execution_count": 7, |
| 142 | + "metadata": {}, |
| 143 | + "outputs": [ |
| 144 | + { |
| 145 | + "name": "stdout", |
| 146 | + "output_type": "stream", |
| 147 | + "text": [ |
| 148 | + "Trailheads - Trailheads\n", |
| 149 | + "\thttps://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0\n", |
| 150 | + "Trails - Trails 0\n", |
| 151 | + "\thttps://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0\n" |
| 152 | + ] |
| 153 | + } |
| 154 | + ], |
| 155 | + "source": [ |
| 156 | + "for lyr in op_layers:\n", |
| 157 | + " print(\"{}\\n\\t{}\".format(lyr['title'], lyr['url']))" |
| 158 | + ] |
| 159 | + } |
| 160 | + ], |
| 161 | + "metadata": { |
| 162 | + "anaconda-cloud": {}, |
| 163 | + "kernelspec": { |
| 164 | + "display_name": "Python [conda env:arcgis-pyapi]", |
| 165 | + "language": "python", |
| 166 | + "name": "conda-env-arcgis-pyapi-py" |
| 167 | + }, |
| 168 | + "language_info": { |
| 169 | + "codemirror_mode": { |
| 170 | + "name": "ipython", |
| 171 | + "version": 3 |
| 172 | + }, |
| 173 | + "file_extension": ".py", |
| 174 | + "mimetype": "text/x-python", |
| 175 | + "name": "python", |
| 176 | + "nbconvert_exporter": "python", |
| 177 | + "pygments_lexer": "ipython3", |
| 178 | + "version": "3.5.3" |
| 179 | + } |
| 180 | + }, |
| 181 | + "nbformat": 4, |
| 182 | + "nbformat_minor": 2 |
| 183 | +} |
0 commit comments