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

  • Supported package types include the following:

    • 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)
    • 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 already 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 inside a package are supporting files, such as a .pdf, .docx, or an image. You will need to browse to the extracted directory in Windows Explorer to open these files.

  • When extracting vector tile packages (.vtpk), the contents of the package are extracted to the output folder, and the cache storage format is converted from compact (.bundle files) to exploded (.pbf files). You can use the extracted .pbf files in other client applications, such as Mapbox, if needed.

  • When extracting tile packages (.tpk, .tpkx, or .vtpk), the Cache Package parameter is disabled.

Syntax

ExtractPackage(in_package, output_folder, {cache_package})
ParameterExplanationData Type
in_package

The input package that will be extracted.

File
output_folder

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

If the specified folder does not exist, a new 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 if necessary. You do not need to manually create a cached version of the package in your user profile when using this setting.

  • CACHE Packages will extract a copy to be cached to your profile. This is the default.
  • NO_CACHEPackages will only extract to the output parameter specified.
Boolean

Code sample

ExtractPackage example 1 (Python window)

The following Python window script demonstrates how to use the ExtractPackage tool.

import arcpy
arcpy.env.workspace = "C:/arcgis/ArcTutor/Getting_Started/Greenvalley" 
arcpy.ExtractPackage_management('WaterUsePackage.lpk', 
                                'C:/My_Data/Packages/WaterUse_unpacked')
ExtractPackage example 2 (stand-alone script)

Find all geoprocesssing packages in a specified folder and use the ExtractPackage tool to extract contents to the specified folder.

# Name: ExtractPackage.py
# Description: Find Geoprocesssing Packages within 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.ExtractPackage_management(gpk, os.path.splitext(gpk)[0])

print("done")

Environments

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics