Extracts the contents of a package to a specified folder. The output folder will be updated with the extracted contents of the input package.
Supported package types include the following:
- Geoprocessing Packages (.gpk)
- Layer Packages (.lpk and .lpkx)
- Map Packages (.mpk and .mpkx)
- Mobile Map Packages (.mmpk)
- Project Packages and Project Templates (.ppkx and .aptx)
- Locator Packages (.gcpk)
- Tile Packages (.tpk)
- 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 into 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.
ExtractPackage_management (in_package, output_folder)
The input package that will be extracted.
The output folder to contain the contents of the package.
ExtractPackage example 1 (Python window)
The following Python window script demonstrates how to use the ExtractPackage tool.
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 within 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)) print("done")
- ArcGIS Desktop Basic: Yes
- ArcGIS Desktop Standard: Yes
- ArcGIS Desktop Advanced: Yes