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.
# 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.
gis.content.create_folder('packages')
{'id': 'e5d78c5d26814691bcf539ba334dce72', 'title': 'packages', 'username': 'arcgis_python'}
tpk_item = gis.content.add({}, data='data/USA_counties_divorce_rate.tpk', folder='packages')
tpk_item
Now, let us go ahead and publish this item as a tile layer
tile_layer = tpk_item.publish()
tile_layer
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
# upload vector tile package to the portal
vtpk_item = gis.content.add({}, data='data/World_earthquakes_2010.vtpk', folder='packages')
vtpk_item
# publish that item as a vector tile layer
vtpk_layer = vtpk_item.publish()
vtpk_layer
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
slpk_item = gis.content.add({}, data='data/World_earthquakes_2000_2010.slpk', folder='packages')
slpk_item
slpk_layer = slpk_item.publish()
slpk_layer