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:
- GeoprocessingPackages (.gpk)
- Layer Packages (.lpk)
- Map Packages (.mpk)
- Locator Packages (.gcpk)
- Tile Packages (.tpk)
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.
Syntax
Parameter | Explanation | Data Type |
in_package |
The input package that will be extracted. | File |
output_folder |
The output folder to contain the contents of the package. | Folder |
Code Sample
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')
Find all Geoprocesssing Packages within a specified folder and use the ExtractPackage tool to extract contents to specified folder.
# Name: ExtractPackage.py
# Description: Find Geoprocesssing Packages within a specified folder and extract contents.
import arcpy
import os
from arcpy import env
env.overwriteOutput = True
# set folder that contains packages to extract
env.workspace = "C:/geoprocessing/gpks"
wrksp = env.workspace
for gpk in arcpy.ListFiles("*.gpk"):
print "Extracting... " + gpk
arcpy.ExtractPackage_management(gpk, os.path.splitext(gpk)[0])
print "done"