Extract Package (Data Management)

Summary

Extracts the contents of a package to a specified folder. The output folder will be updated with the extracted contents of the input package.

Usage

  • The following are supported package types:

    • Geoprocessing Packages (.gpk and .gpkx)
    • Layer Packages (.lpk and .lpkx)
    • Locator Packages (.gcpk)
    • Map Packages (.mpk and .mpkx)
    • Mobile Map Packages (.mmpk)
    • Project Packages and Project Templates (.ppkx and .aptx)
    • Scene Layer Packages (.slpk)
    • Tile Packages (.tpk and .tpkx)
    • Vector Tile Packages (.vtpk)

  • The output folder can be a new folder or an existing folder. When extracting to an existing folder, the contents of the package will be appended to existing files and folders. If the output folder contains the extracted contents of the package, the existing contents will be overwritten.

  • Packages with attachments will have their attached files unpacked to the commondata\userdata\ subfolder in the output folder. Typically, the files in a package are supporting files, such as .pdf or .docx, or an image. Browse to the extracted directory in Microsoft File Explorer to open these files.

  • When extracting vector tile packages (.vtpk), the contents of the package will be extracted to the output folder. The cache storage format can be converted from compact (.bundle files) to exploded (.pbf files) using the Storage Format Type parameter. You can use the extracted .pbf files in other client applications, such as Mapbox.

    Note:

    Extracting a flat cache may be slow and result in the extraction of billions of tiles depending on the data extent, levels of detail of the package, and hardware configuration.

  • When extracting vector, tile, or scene layer packages (.vtpk, .tpk, .tpkx, or .slpk), the Cache Package parameter is inactive.

  • When extracting vector, tile, or version 1.7 and later scene layer packages, you can extract the contents of the package to a folder in the file system or to an object store located in the cloud such as Amazon S3, Azure Blob storage, or Alibaba OSS. This content is ready to serve as a tile or scene layer and the location you choose must be registered as a user-managed data store in ArcGIS Enterprise.

  • You can build a connection file (.acs) using the Create Cloud Storage Connection File tool.

  • Older versions of scene layer packages can be upgraded to the latest version using the Upgrade Scene Layer tool.

  • Note:

    When extracting scene layer packages to an object store in the cloud (.i3sREST), the scene cache storage format is not the same as when extracting to a folder in the file system (.eslpk), and the two formats are not interchangeable.

Parameters

LabelExplanationData Type
Input Package

The input package that will be extracted.

File
Output Folder
(Optional)

The output folder that will contain the contents of the package.

If the specified folder does not exist, a folder will be created.

Folder
Cache Package
(Optional)

Specifies whether a copy of the package will be cached to your profile.

When extracting a package, the output is first extracted to your user profile and appended with a unique ID before a copy is made to the directory specified in the Output Folder parameter. Downloading and extracting subsequent versions of the same package will only update this location. You do not need to manually create a cached version of the package in your user profile when using this parameter. This parameter is not active if the input package is a vector tile package (.vtpk) or a tile package (.tpk and .tpkx).

  • Checked—A copy of the package will be extracted and cached to your profile. This is the default.
  • Unchecked—A copy of the package will only be extracted to the output parameter specified; it will not be cached.
Boolean
Storage Format Type
(Optional)

Specifies the storage format that will be used for the extracted cache. This parameter is applicable only when the input package is a vector tile package (.vtpk).

  • Compact The tiles will be grouped in bundle files using the Compact V2 storage format. This format provides better performance on network shares and cloud store directories. This is the default.
  • Exploded Each tile will be stored as an individual file.
String
Create Ready To Serve Cache Dataset
(Optional)

Specifies whether a ready-to-serve format for ArcGIS Enterprise will be created. This parameter is active only when the input package is a vector tile package (.vtpk) or a tile package (.tpkx).

  • Checked—A folder structure with an extracted cache that can be used to create a tile layer in ArcGIS Enterprise will be created. The file extension of the folder signifies the content it stores: .tiles (cache dataset) for tile layer packages or .vtiles (vector cache dataset) for vector tile packages.
  • Unchecked—A folder structure with extracted contents of the package will be created. This is the default.
Boolean
Target Cloud Connection
(Optional)

The target .acs file to which the package contents will be extracted. This parameter is enabled only when the input package is a scene layer package (.slpk), a vector tile package (.vtpk), or a tile package (.tpkx).

Folder

arcpy.management.ExtractPackage(in_package, {output_folder}, {cache_package}, {storage_format_type}, {create_ready_to_serve_format}, {target_cloud_connection})
NameExplanationData Type
in_package

The input package that will be extracted.

File
output_folder
(Optional)

The output folder that will contain the contents of the package.

If the specified folder does not exist, a folder will be created.

Folder
cache_package
(Optional)

Specifies whether a copy of the package will be cached to your profile.

When extracting a package, the output is first extracted to your user profile and appended with a unique ID before a copy is made to the directory specified in the output_folder parameter. Downloading and extracting subsequent versions of the same package will only update this location. You do not need to manually create a cached version of the package in your user profile when using this parameter. This parameter is not enabled if the input package is a vector tile package (.vtpk) or a tile package (.tpk and .tpkx).

  • CACHE A copy of the package will be extracted and cached to your profile. This is the default.
  • NO_CACHEA copy of the package will only be extracted to the output parameter specified; it will not be cached.
Boolean
storage_format_type
(Optional)

Specifies the storage format that will be used for the extracted cache. This parameter is applicable only when the input package is a vector tile package (.vtpk).

  • COMPACT The tiles will be grouped in bundle files using the Compact V2 storage format. This format provides better performance on network shares and cloud store directories. This is the default.
  • EXPLODED Each tile will be stored as an individual file.
String
create_ready_to_serve_format
(Optional)

Specifies whether a ready-to-serve format for ArcGIS Enterprise will be created. This parameter is enabled only when the input package is a vector tile package (.vtpk) or a tile package (.tpkx).

  • READY_TO_SERVE_CACHE_DATASETA folder structure with an extracted cache that can be used to create a tile layer in ArcGIS Enterprise will be created. The file extension of the folder signifies the content it stores: .tiles (cache dataset) for tile layer packages or .vtiles (vector cache dataset) for vector tile packages.
  • EXTRACTED_PACKAGEA folder structure with extracted contents of the package will be created. This is the default.
Boolean
target_cloud_connection
(Optional)

The target .acs file to which the package contents will be extracted. This parameter is enabled only when the input package is a scene layer package (.slpk), a vector tile package (.vtpk), or a tile package (.tpkx).

Folder

Code sample

ExtractPackage example 1 (Python window)

The following Python window script demonstrates how to use the ExtractPackage function to generate ready-to-serve cache datasets that can be used in ArcGIS Enterprise publishing workflows.

import arcpy
arcpy.management.ExtractPackage(r"C:\Data\packages\MyVectorPackage.vtpk", 
                                r"C:\Data\packages\Extracted", "CACHE", 
                                "COMPACT", "READY_TO_SERVE_CACHE_DATASET")
ExtractPackage example 2 (Python window)

The following Python window script demonstrates how to use the ExtractPackage function to extract scene layer packages to an object store that can be used in ArcGIS Enterprise publishing workflows.

import arcpy
arcpy.management.ExtractPackage(r"C:\Data\packages\ChicagoBuildings.slpk", 
                                None, "CACHE", 
                                "COMPACT", "EXTRACTED_PACKAGE", 
                                r"C:\CloudConnections\AWS.acs")
ExtractPackage example 3 (Python window)

The following Python window script demonstrates how to use the ExtractPackage function to extract vector tile layer packages to an object store that can be used in ArcGIS Enterprise publishing workflows.

import arcpy
arcpy.management.ExtractPackage(r"C:\Data\packages\London.vtpk", 
                                None, "CACHE", 
                                "COMPACT", "EXTRACTED_PACKAGE", 
                                r"C:\CloudConnections\AWS.acs")
ExtractPackage example 4 (stand-alone script)

Find all geoprocessing packages in a specified folder and use the ExtractPackage function to extract contents to the specified folder.

# Name: ExtractPackage.py
# Description: Find geoprocessing packages in a specified folder and extract 
#              contents.

import arcpy
import os

arcpy.env.overwriteOutput = True

# set folder that contains packages to extract
arcpy.env.workspace = "C:/geoprocessing/gpks" 
wrksp = arcpy.env.workspace

for gpk in arcpy.ListFiles("*.gpk"):
    print("Extracting... " + gpk)
    arcpy.management.ExtractPackage(gpk, os.path.splitext(gpk)[0])

print("done")

Environments

Related topics