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.

In [ ]:
# connect to the GIS
from arcgis.gis import GIS
gis = GIS("https://python.playground.esri.com/portal", "arcgis_python", "amazing_arcgis_123")

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.

In [ ]:
gis.content.create_folder('packages')
Out[ ]:
{'id': '6c7e7716ec0f4b9da0c26763dd4563cd',
 'title': 'packages',
 'username': 'arcgis_python'}
In [ ]:
tpk_item = gis.content.add({}, data='data/USA_counties_divorce_rate.tpk', folder='packages')
tpk_item
Out[ ]:
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 23, 2017
0 comments, 0 views

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

In [ ]:
tile_layer = tpk_item.publish()
tile_layer
Out[ ]:
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 23, 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

In [ ]:
# upload vector tile package to the portal
vtpk_item = gis.content.add({}, data='data/World_earthquakes_2010.vtpk', folder='packages')
vtpk_item
Out[ ]:
World_earthquakes_2010
World earthquakes in 2010Vector Tile Package by arcgis_python
Last Modified: June 23, 2017
0 comments, 0 views
In [ ]:
# publish that item as a vector tile layer
vtpk_layer = vtpk_item.publish()
In [ ]:
vtpk_layer
Out[ ]:
World_earthquakes_2010
World earthquakes in 2010Vector Tile Layer by arcgis_python
Last Modified: June 23, 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

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

Feedback on this topic?