Create Map Tile Package (Data Management)
Summary
Generates tiles from a map document and packages the tiles to create a single compressed .tpk file.
Usage
-
The input map document must have description and tags in order for the tool to execute. To add description and tags, choose File > Map Document Properties from the main menu and enter description and tags.
By choosing PNG for the Tiling Format parameter, the tool will automatically select the correct format (PNG8, PB24, or PNG32) based on the specified Level of Display.
-
To unpack a map tile package, either drag the .tpk file into ArcMap or right-click on the .tpk in the Catalog window file and select Unpack. Alternatively, you can use the Extract_Package tool and specify an output folder.
By default, Unpack will always extract the package into your user profile under:
- XP—C:\Documents and Settings\<username>\My Documents\ArcGIS\Packages
- Vista and Windows 7—C:\Users\<username>\Documents\ArcGIS\Packages
To change the default location of where your packages will be unpacked, open ArcMap Options from the Customize menu. From the Sharing tab find the Packaging section and check Use user specified location and browse to the new folder location.
Syntax
Parameter | Explanation | Data Type |
in_map | The map document from which tiles will be generated and packaged. | ArcMap Document |
service_type | Determines whether the tiling scheme will be generated from an existing map service or if map tiles will be generated for ArcGIS Online, Bing maps, and Google Maps.
| Boolean |
output_file | The output map tile package. | File |
format_type | Specifies the format of the generated tiles.
| String |
level_of_detail | Specify the number of scale levels at which tiles will be generated for the package. Possible values are 1 through 20. | Long |
service_file (Optional) | Specifies the name of the map service or the XML files to use for the tiling scheme. This parameter is required only when the service_type parameter is EXISTING. | MapServer; File |
summary (Optional) | Adds summary information to the properties of the package. | String |
tags (Optional) | Adds tag information to the properties of the package. Multiple tags can be added separated by a comma or semicolon. | String |
Code Sample
The following Python script demonstrates how to use the CreateMapTilePackage tool from the Python window.
import arcpy
arcpy.env.workspace = "C:/TilePackageExample"
arcpy.CreateMapTilePackage_management('Example.mxd', "ONLINE", 'Example.tpk', "PNG8", "10")
Find and create map tile packages for all map documents that reside in a specified folder.
# Name: CreateMapTilePackage.py
# Description: Find all the map documents that reside in a specified folder and create tile packages for each map document.
# import system modules
import os
import arcpy
from arcpy import env
# Set environment settings
env.overwriteOutput = True
env.workspace = "C:/Tilepackages/"
# Loop through the workspace, find all the mxds and create a tile package using the same name as the mxd
for mxd in arcpy.ListFiles("*.mxd"):
print "Packaging " + mxd
arcpy.CreateMapTilePackage_management(mxd, "ONLINE", os.path.splitext(mxd)[0] + '.tpk', "PNG8", "10")