Publishing packages as web layers

Packages in ArcGIS bundle maps, data, tools and cartographic information. ArcGIS lets you create a variety of packages 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.

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.

Publishing tile layers from a tile package

A Tile package 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.

Input
# connect to the GIS
from arcgis.gis import GIS
gis = GIS("https://pythonapi.playground.esri.com/portal")

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.

Input
gis.content.create_folder('packages')
Output
{'id': 'e5d78c5d26814691bcf539ba334dce72',
 'title': 'packages',
 'username': 'arcgis_python'}
Input
tpk_item = gis.content.add({}, data='data/USA_counties_divorce_rate.tpk', folder='packages')
tpk_item
Output
USA_counties_divorce_rate
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
Last Modified: June 26, 2017
0 comments, 0 views

Now, let us go ahead and publish this item as a tile layer

Input
tile_layer = tpk_item.publish()
tile_layer
Output
USA_counties_divorce_rate
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
Last Modified: June 26, 2017
0 comments, 0 views

Publishing vector tile layers from a vector tile package

A vector tile package 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.

Let us upload a World_earthquakes_2010.vtpk vector tile package like earlier and publish that as a vector tile service

Input
# upload vector tile package to the portal
vtpk_item = gis.content.add({}, data='data/World_earthquakes_2010.vtpk', folder='packages')
vtpk_item
Output
World_earthquakes_2010
World earthquakes in 2010Vector Tile Package by arcgis_python
Last Modified: June 26, 2017
0 comments, 0 views
Input
# publish that item as a vector tile layer
vtpk_layer = vtpk_item.publish()
Input
vtpk_layer
Output
World_earthquakes_2010
World earthquakes in 2010Vector Tile Layer by arcgis_python
Last Modified: June 26, 2017
0 comments, 0 views

Publishing scene layers from a scene layer package

A scene layer package 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.

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

Input
slpk_item = gis.content.add({}, data='data/World_earthquakes_2000_2010.slpk', folder='packages')
slpk_item
Output
World_earthquakes_2000_2010
Scene Package by arcgis_python
Last Modified: June 26, 2017
0 comments, 0 views
Input
slpk_layer = slpk_item.publish()
slpk_layer
Output
World_earthquakes_2000_2010
Scene Layer by arcgis_python
Last Modified: June 26, 2017
0 comments, 0 views

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.