From fbb8c53cec82f0168676c1b6eb2997518308e6fd Mon Sep 17 00:00:00 2001 From: Shuang Song <103439749+cariashuang0417@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:00:44 -0400 Subject: [PATCH] type --- .../publishing_packages_as_web_layers.ipynb | 408 +++++++++++++++++- 1 file changed, 407 insertions(+), 1 deletion(-) diff --git a/samples/05_content_publishers/publishing_packages_as_web_layers.ipynb b/samples/05_content_publishers/publishing_packages_as_web_layers.ipynb index 7438a4ce2..c2fd22c9a 100644 --- a/samples/05_content_publishers/publishing_packages_as_web_layers.ipynb +++ b/samples/05_content_publishers/publishing_packages_as_web_layers.ipynb @@ -1 +1,407 @@ -{"cells":[{"cell_type":"markdown","metadata":{},"source":["# Publishing packages as web layers"]},{"cell_type":"markdown","metadata":{"toc":true},"source":["

Table of Contents

\n","
"]},{"cell_type":"markdown","metadata":{},"source":["Packages in ArcGIS bundle maps, data, tools and cartographic information. ArcGIS lets you [create a variety of packages](http://pro.arcgis.com/en/pro-app/help/sharing/overview/introduction-to-sharing-packages.htm) such as map (.mpkx), layer (.lpkx), map tile (.tpk), vector tile (.vtpk), scene layer (.slpk), geoprocessing (.gpkx) packages etc. to name a few. You can share any of these packages with other users either as files on a network share or as items in your portal. In addition, some of these packages can be shared as web layers.\n","\n","In this sample, we will observe how to publish web layers from tile, vector tile and scene layer packages. Data for this sample is available in the accompanying `data` folder.\n","\n","## Publishing tile layers from a tile package\n","\n","A [Tile package](http://pro.arcgis.com/en/pro-app/help/sharing/overview/tile-package.htm) contains a set of tiles (images) from a map or raster dataset. These tiles (also called as tile cache) can be used as basemaps and are useful for visualizing imagery or relatively static data."]},{"cell_type":"code","execution_count":null,"metadata":{"collapsed":true},"outputs":[],"source":["# connect to the GIS\n","from arcgis.gis import GIS\n","gis = GIS(\"https://pythonapi.playground.esri.com/portal\")"]},{"cell_type":"markdown","metadata":{"collapsed":true},"source":["Upload the tile package (USA_counties_divorce_rate.tpk) as an item. To keep our 'my contents' tidy, let us create a new folder called 'packages' and add to it."]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[{"data":{"text/plain":["{'id': 'e5d78c5d26814691bcf539ba334dce72',\n"," 'title': 'packages',\n"," 'username': 'arcgis_python'}"]},"execution_count":null,"metadata":{},"output_type":"execute_result"}],"source":["folder_manager = gis.content.folders\n","folder = folder_manager.create('packages')"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[{"data":{"text/html":["
\n","
\n"," \n"," \n"," \n","
\n","\n","
\n"," USA_counties_divorce_rate\n"," \n","
A map exploring the ratio of number of divorced to the total number of households. This visualizes the counties that have a higher divorce rate.Tile Package by arcgis_python\n","
Last Modified: June 26, 2017\n","
0 comments, 0 views\n","
\n","
\n"," "],"text/plain":[""]},"execution_count":null,"metadata":{},"output_type":"execute_result"}],"source":["tpk_item = folder.add({\"title\": \"USA_counties_divorce_rate\", \"item_type\": \"Tile Package\"}, file='data/USA_counties_divorce_rate.tpk').result()\n","tpk_item"]},{"cell_type":"markdown","metadata":{},"source":["Now, let us go ahead and publish this item as a tile layer"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[{"data":{"text/html":["
\n","
\n"," \n"," \n"," \n","
\n","\n","
\n"," USA_counties_divorce_rate\n"," \n","
A map exploring the ratio of number of divorced to the total number of households. This visualizes the counties that have a higher divorce rate.Map Image Layer by arcgis_python\n","
Last Modified: June 26, 2017\n","
0 comments, 0 views\n","
\n","
\n"," "],"text/plain":[""]},"execution_count":null,"metadata":{},"output_type":"execute_result"}],"source":["tile_layer = tpk_item.publish()\n","tile_layer"]},{"cell_type":"markdown","metadata":{},"source":["## Publishing vector tile layers from a vector tile package\n","\n","A [vector tile package](http://pro.arcgis.com/en/pro-app/help/sharing/overview/vector-tile-package.htm) is a collection of vector tiles and style resources. Vector tiles contain vector representations of data across a range of scales. Unlike raster tiles, they can adapt to the resolution of the display device and even be customized for multiple uses.\n","\n","Let us upload a World_earthquakes_2010.vtpk vector tile package like earlier and publish that as a vector tile service"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[{"data":{"text/html":["
\n","
\n"," \n"," \n"," \n","
\n","\n","
\n"," World_earthquakes_2010\n"," \n","
World earthquakes in 2010Vector Tile Package by arcgis_python\n","
Last Modified: June 26, 2017\n","
0 comments, 0 views\n","
\n","
\n"," "],"text/plain":[""]},"execution_count":null,"metadata":{},"output_type":"execute_result"}],"source":["# upload vector tile package to the portal\n","vtpk_item = folder.add({\"title\": \"World_earthquakes_2010\", \"item_type\": \"Vector Tile Package\"}, file='data/World_earthquakes_2010.vtpk').result()\n","vtpk_item"]},{"cell_type":"code","execution_count":null,"metadata":{"collapsed":true},"outputs":[],"source":["# publish that item as a vector tile layer\n","vtpk_layer = vtpk_item.publish()"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[{"data":{"text/html":["
\n","
\n"," \n"," \n"," \n","
\n","\n","
\n"," World_earthquakes_2010\n"," \n","
World earthquakes in 2010Vector Tile Layer by arcgis_python\n","
Last Modified: June 26, 2017\n","
0 comments, 0 views\n","
\n","
\n"," "],"text/plain":[""]},"execution_count":null,"metadata":{},"output_type":"execute_result"}],"source":["vtpk_layer"]},{"cell_type":"markdown","metadata":{"collapsed":true},"source":["## Publishing scene layers from a scene layer package\n","\n","A [scene layer package](http://pro.arcgis.com/en/pro-app/help/sharing/overview/scene-layer-package.htm) contains a cache of a multipatch, point, or point cloud dataset and is used to visualize 3D data. You can publish this package and create a web scene layer which can be visualized on a web scene.\n","\n","Let us publish a 'World_earthquakes_2000_2010.slpk' scene layer package that visualizes global earthquakes between the years 2000 and 2010 in 3 dimension"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[{"data":{"text/html":["
\n","
\n"," \n"," \n"," \n","
\n","\n","
\n"," World_earthquakes_2000_2010\n"," \n","
Scene Package by arcgis_python\n","
Last Modified: June 26, 2017\n","
0 comments, 0 views\n","
\n","
\n"," "],"text/plain":[""]},"execution_count":null,"metadata":{},"output_type":"execute_result"}],"source":["slpk_item = folder.add({\"title\": \"World_earthquakes_2010\", \"item_type\": \"Scene Package\"}, file='data/World_earthquakes_2000_2010.slpk').result()\n","slpk_item"]},{"cell_type":"code","execution_count":null,"metadata":{},"outputs":[{"data":{"text/html":["
\n","
\n"," \n"," \n"," \n","
\n","\n","
\n"," World_earthquakes_2000_2010\n"," \n","
Scene Layer by arcgis_python\n","
Last Modified: June 26, 2017\n","
0 comments, 0 views\n","
\n","
\n"," "],"text/plain":[""]},"execution_count":null,"metadata":{},"output_type":"execute_result"}],"source":["slpk_layer = slpk_item.publish()\n","slpk_layer"]}],"metadata":{"anaconda-cloud":{},"esriNotebookRuntime":{"notebookRuntimeName":"ArcGIS Notebook Python 3 Standard","notebookRuntimeVersion":"4.0"},"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"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.8.2"},"toc":{"base_numbering":1,"nav_menu":{},"number_sections":true,"sideBar":true,"skip_h1_title":false,"title_cell":"Table of Contents","title_sidebar":"Contents","toc_cell":true,"toc_position":{},"toc_section_display":true,"toc_window_display":true}},"nbformat":4,"nbformat_minor":1} +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Publishing packages as web layers" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "toc": true + }, + "source": [ + "

Table of Contents

\n", + "" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Packages in ArcGIS bundle maps, data, tools and cartographic information. ArcGIS lets you [create a variety of packages](http://pro.arcgis.com/en/pro-app/help/sharing/overview/introduction-to-sharing-packages.htm) such as map (.mpkx), layer (.lpkx), map tile (.tpk), vector tile (.vtpk), scene layer (.slpk), geoprocessing (.gpkx) packages etc. to name a few. You can share any of these packages with other users either as files on a network share or as items in your portal. In addition, some of these packages can be shared as web layers.\n", + "\n", + "In this sample, we will observe how to publish web layers from tile, vector tile and scene layer packages. Data for this sample is available in the accompanying `data` folder.\n", + "\n", + "## Publishing tile layers from a tile package\n", + "\n", + "A [Tile package](http://pro.arcgis.com/en/pro-app/help/sharing/overview/tile-package.htm) contains a set of tiles (images) from a map or raster dataset. These tiles (also called as tile cache) can be used as basemaps and are useful for visualizing imagery or relatively static data." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true, + "jupyter": { + "outputs_hidden": true + } + }, + "outputs": [], + "source": [ + "# connect to the GIS\n", + "from arcgis.gis import GIS\n", + "gis = GIS(\"https://pythonapi.playground.esri.com/portal\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true, + "jupyter": { + "outputs_hidden": true + } + }, + "source": [ + "Upload the tile package (USA_counties_divorce_rate.tpk) as an item. To keep our 'my contents' tidy, let us create a new folder called 'packages' and add to it." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'id': 'e5d78c5d26814691bcf539ba334dce72',\n", + " 'title': 'packages',\n", + " 'username': 'arcgis_python'}" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "folder_manager = gis.content.folders\n", + "folder = folder_manager.create('packages')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "
\n", + " \n", + " \n", + " \n", + "
\n", + "\n", + "
\n", + " USA_counties_divorce_rate\n", + " \n", + "
A map exploring the ratio of number of divorced to the total number of households. This visualizes the counties that have a higher divorce rate.Tile Package by arcgis_python\n", + "
Last Modified: June 26, 2017\n", + "
0 comments, 0 views\n", + "
\n", + "
\n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tpk_item = folder.add({\"title\": \"USA_counties_divorce_rate\", \"type\": \"Tile Package\"}, file='data/USA_counties_divorce_rate.tpk').result()\n", + "tpk_item" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Now, let us go ahead and publish this item as a tile layer" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "
\n", + " \n", + " \n", + " \n", + "
\n", + "\n", + "
\n", + " USA_counties_divorce_rate\n", + " \n", + "
A map exploring the ratio of number of divorced to the total number of households. This visualizes the counties that have a higher divorce rate.Map Image Layer by arcgis_python\n", + "
Last Modified: June 26, 2017\n", + "
0 comments, 0 views\n", + "
\n", + "
\n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tile_layer = tpk_item.publish()\n", + "tile_layer" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Publishing vector tile layers from a vector tile package\n", + "\n", + "A [vector tile package](http://pro.arcgis.com/en/pro-app/help/sharing/overview/vector-tile-package.htm) is a collection of vector tiles and style resources. Vector tiles contain vector representations of data across a range of scales. Unlike raster tiles, they can adapt to the resolution of the display device and even be customized for multiple uses.\n", + "\n", + "Let us upload a World_earthquakes_2010.vtpk vector tile package like earlier and publish that as a vector tile service" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "
\n", + " \n", + " \n", + " \n", + "
\n", + "\n", + "
\n", + " World_earthquakes_2010\n", + " \n", + "
World earthquakes in 2010Vector Tile Package by arcgis_python\n", + "
Last Modified: June 26, 2017\n", + "
0 comments, 0 views\n", + "
\n", + "
\n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# upload vector tile package to the portal\n", + "vtpk_item = folder.add({\"title\": \"World_earthquakes_2010\", \"type\": \"Vector Tile Package\"}, file='data/World_earthquakes_2010.vtpk').result()\n", + "vtpk_item" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true, + "jupyter": { + "outputs_hidden": true + } + }, + "outputs": [], + "source": [ + "# publish that item as a vector tile layer\n", + "vtpk_layer = vtpk_item.publish()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "
\n", + " \n", + " \n", + " \n", + "
\n", + "\n", + "
\n", + " World_earthquakes_2010\n", + " \n", + "
World earthquakes in 2010Vector Tile Layer by arcgis_python\n", + "
Last Modified: June 26, 2017\n", + "
0 comments, 0 views\n", + "
\n", + "
\n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vtpk_layer" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true, + "jupyter": { + "outputs_hidden": true + } + }, + "source": [ + "## Publishing scene layers from a scene layer package\n", + "\n", + "A [scene layer package](http://pro.arcgis.com/en/pro-app/help/sharing/overview/scene-layer-package.htm) contains a cache of a multipatch, point, or point cloud dataset and is used to visualize 3D data. You can publish this package and create a web scene layer which can be visualized on a web scene.\n", + "\n", + "Let us publish a 'World_earthquakes_2000_2010.slpk' scene layer package that visualizes global earthquakes between the years 2000 and 2010 in 3 dimension" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "
\n", + " \n", + " \n", + " \n", + "
\n", + "\n", + "
\n", + " World_earthquakes_2000_2010\n", + " \n", + "
Scene Package by arcgis_python\n", + "
Last Modified: June 26, 2017\n", + "
0 comments, 0 views\n", + "
\n", + "
\n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "slpk_item = folder.add({\"title\": \"World_earthquakes_2010\", \"type\": \"Scene Package\"}, file='data/World_earthquakes_2000_2010.slpk').result()\n", + "slpk_item" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "
\n", + " \n", + " \n", + " \n", + "
\n", + "\n", + "
\n", + " World_earthquakes_2000_2010\n", + " \n", + "
Scene Layer by arcgis_python\n", + "
Last Modified: June 26, 2017\n", + "
0 comments, 0 views\n", + "
\n", + "
\n", + " " + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "slpk_layer = slpk_item.publish()\n", + "slpk_layer" + ] + } + ], + "metadata": { + "anaconda-cloud": {}, + "esriNotebookRuntime": { + "notebookRuntimeName": "ArcGIS Notebook Python 3 Standard", + "notebookRuntimeVersion": "4.0" + }, + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "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.11.0" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": true, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": true + } + }, + "nbformat": 4, + "nbformat_minor": 4 +}