Package Layer (Data Management)

Summary

Packages one or more layers and all referenced data sources to create a single compressed .lpk file.

Illustration

Package Layer illustration
The folder structure of an unpacked layer package that contains three feature layers.

Usage

Syntax

PackageLayer_management (in_layer, output_file, {convert_data}, {convert_arcsde_data}, {extent}, {apply_extent_to_arcsde}, {schema_only}, {version})
ParameterExplanationData Type
in_layer
[in_layer,...]

The layers to package.

Layer
output_file

The location and name of the output package file (.lpk) to create.

File
convert_data
(Optional)

Specifies whether input layers will be converted into file geodatabase or preserve their original format.

  • CONVERT Data will be copied to a file geodatabase.
  • PRESERVE Data formats will be preserved. This is the default.
Boolean
convert_arcsde_data
(Optional)

Specifies whether input layers will be converted into file geodatabase or preserve their original format.

  • CONVERT_ARCSDE ArcSDE data will be copied to a file geodatabase. This is the default.
  • PRESERVE_ARCSDE ArcSDE data will be preserved and will be referenced in the resulting consolidated folder or package.
Boolean
extent
(Optional)

Specify the extent by manually entering the coordinates in the extent parameter using the format X-Min Y-Min X-Max Y-Max. Additionally, to use the extent of a specific layer, simply add the layer name for the extent parameter.

  • MAXOFUnion of inputs
  • MINOFIntersection of inputs
  • DISPLAYSame as Display
  • <Layer>Same as Layer...
Extent
apply_extent_to_arcsde
(Optional)

Specifies the extent that will be used to select ArcSDE data sources.

  • ALL Specified extent is applied to all layers. This is the default.
  • ARCSDE_ONLYSpecified extent is applied to ArcSDE layers only.
Boolean
schema_only
(Optional)

Specifies whether the schema of the input layers will be consolidated or packaged.

  • ALL All features and records will be consolidated or packaged. This is the default.
  • SCHEMA_ONLY Only the Schema of input layers will be consolidated pr packaged.
Boolean
version
[version,...]
(Optional)

Specifies if input layers will be converted into a file geodatabase or preserve their original format. For multiple versions, use semicolons to separate the arguments. For example: "CURRENT;9.3.1"

  • CURRENT Output geodatabase(s) will have the same version as the current release.
  • 10 Output geodatabase(s) will be compatible with version 10.
  • 9.3.1Output geodatabase(s) will be compatible version 9.3.1.
String

Code Sample

PackageLayer Example (Python Window)

The following Python script demonstrates how to use the PackageLayer tool from within the Python window.

import arcpy
arcpy.env.workspace = "C:/arcgis/ArcTutor/BuildingaGeodatabase/Layers" 
arcpy.PackageLayer_management('Parcel.lyr', 'Parcel.lpk', "PRESERVE", "CONVERT_ARCSDE", "#", "ALL", "AlL", "CURRENT")
PackageLayer Example 1 (stand-alone Python script)

Finds and creates individual layer packages for all of the layer files that reside in a specified folder.

# Name: PackageLayerEx1.py
# Description:  Find all the layer files that reside in a specified folder and create a layer package for each layer file.
# Author: ESRI

# import system modules
import os
import arcpy

from arcpy import env

# Set environment settings
env.overwriteOutput = True
env.workspace = "C:/arcgis/ArcTutor/BuildingaGeodatabase/Layers" 

# Loop through the workspace, find all the layer files (.lyr) and create a layer package using the same name as the original layer file.
for lyr in arcpy.ListFiles("*.lyr"):
    print "Packaging " + lyr
    arcpy.PackageLayer_management(lyr, os.path.splitext(lyr)[0] + '.lpk', "PRESERVE", "CONVERT_ARCSDE", "#", "ALL", "ALL", "CURRENT")
PackageLayer Example 2 (stand-alone Python script)

Finds and creates a single layer package for all of the layer files that reside in a specified folder.

# Name: PackageLayerEx2.py
# Description:  Find all the layer files that reside in a specified folder and create a single layer package that will contain all layers found.
# Author: ESRI

# import system modules
import os
import arcpy

from arcpy import env

# Set environment settings
env.overwriteOutput = True
env.workspace = "C:/arcgis/ArcTutor/BuildingaGeodatabase/Layers" 

# Find all the layer files (.lyr) in a workspace and create a single layer package.
lyrs = arcpy.ListFiles("*.lyr")
arcpy.PackageLayer_management(lyrs, 'all_layers.lpk', "PRESERVE", "CONVERT_ARCSDE", "#", "ALL", "ALL", "CURRENT")

Environments

Related Topics

Licensing Information

ArcView: Yes
ArcEditor: Yes
ArcInfo: Yes

9/11/2014