arcpy.management.ExtractDataFromGeodatabase(in_data, {extract_type}, {out_type}, {out_geodatabase}, {out_xml}, {out_folder_path}, {out_name}, {expand_feature_classes_and_tables}, {reuse_schema}, {get_related_data}, {extract_using_geometry_features}, {geometry_filter_type}, {all_records_for_tables})
|
Name
|
Explanation
|
Data type
|
|
in_data
[in_data,...]
|
The data that will be extracted.
|
Table View; Dataset
|
|
extract_type
(Optional)
|
Specifies whether the schema and rows of the data or only the schema will be extracted.
|
String
|
|
out_type
(Optional)
|
Specifies the output type the data will be extracted to.
GEODATABASE—The data will be extracted to an existing geodatabase. This is the default.
XML_FILE—The data will be extracted to an XML workspace document.
NEW_FILE_GEODATABASE—The data will be extracted to a new file geodatabase. Specify the location and name of the new file geodatabase using the out_folder_path and out_name parameters.
NEW_MOBILE_GEODATABASE—The data will be extracted to a new mobile geodatabase. Specify the location and name of the new mobile geodatabase using the out_folder_path and out_name parameters.
|
String
|
|
out_geodatabase
(Optional)
|
The geodatabase that will contain the extracted data when the out_type parameter is set to GEODATABASE.
|
Workspace
|
|
out_xml
(Optional)
|
The name and location of the .xml file that will be created when the out_type parameter is set to XML_FILE.
|
File
|
|
out_folder_path
(Optional)
|
The location of the file or mobile geodatabase that will be created for the extracted data. This parameter is required when the out_type parameter is set to NEW_FILE_GEODATABASE or NEW_MOBILE_GEODATABASE.
|
Folder
|
|
out_name
(Optional)
|
The name of the file or mobile geodatabase that will be created for the extracted data. This parameter is required when the out_type parameter is set to NEW_FILE_GEODATABASE or NEW_MOBILE_GEODATABASE.
|
String
|
|
expand_feature_classes_and_tables
(Optional)
|
Specifies whether expanded feature classes and tables—such as those in networks, topologies, or relationship classes—will be added.
USE_DEFAULTS—The expanded feature classes and tables related to the feature classes and tables in the input datasets will be added. The default for feature classes is to extract all features intersecting the spatial filter. If no spatial filter has been provided, all features will be included. The default for tables is to extract the schema only. This is the default.
ADD_WITH_SCHEMA_ONLY—Only the schema for the expanded feature classes and tables will be added.
ALL_ROWS—All rows for expanded feature classes and tables will be added.
DO_NOT_ADD—No expanded feature classes or tables will be added.
|
String
|
|
reuse_schema
(Optional)
|
Specifies whether a geodatabase that contains the schema of the data to be extracted will be reused. Reusing the schema reduces the amount of time required to extract the data.
|
String
|
|
get_related_data
(Optional)
|
Specifies whether rows related to rows existing in the data will be extracted. For example, a feature (f1) is inside the geometry filter and a related feature (f2) from another class is outside the filter. Feature f2 will be included in the extracted data if you choose to get related data.
|
String
|
|
extract_using_geometry_features
(Optional)
|
The features that will be used to define the area to extract.
|
Feature Layer
|
|
geometry_filter_type
(Optional)
|
Specifies the spatial relationship between the extract_using_geometry_features and in_data parameter values and how that relationship will be filtered. The spatial relationship is applied to data in an extent defined by the area of interest (AOI) specified in the extract_using_geometry_features parameter.
INTERSECTS—Features in the in_data parameter value that intersect features in the extract_using_geometry_features parameter value will be extracted. This is the default.
CONTAINS—Features in the in_data parameter value that are contained by the selected feature in the extract_using_geometry_features parameter value will be extracted.
|
String
|
|
all_records_for_tables
(Optional)
|
Specifies whether all records or only the schema will be extracted for tables that do not have filters applied (such as selections or definition queries).
Tables with applied filters will be honored.
ALL_RECORDS_FOR_TABLES—All records will be extracted to the geodatabase. This option will override the expand_feature_classes_and_tables parameter value.
SCHEMA_ONLY_FOR_TABLES—Only the schema will be extracted to the geodatabase. This is the default.
|
Boolean
|
Derived output
|
Name
|
Explanation
|
Data type
|
|
out_workspace
|
The output workspace when the out_type parameter is set to GEODATABASE, NEW_FILE_GEODATABASE, or NEW_MOBILE_GEODATABASE.
|
Workspace
|
Code sample
ExtractDataFromGeodatabase example 1 (Python window)
The following Python window script demonstrates how to use the ExtractDataFromGeodatabase function with a single input feature class and a new output file geodatabase.
import arcpy
arcpy.management.ExtractDataFromGeodatabase(
r"C:\MyProject\MyGDB.gdb\Bridges", "DATA", "NEW_FILE_GEODATABASE", "", "",
r"C:\MyProject", "MyNewGDB")
ExtractDataFromGeodatabase example 2 (Python window)
The following Python window script demonstrates how to use the ExtractDataFromGeodatabase function with multiple layers and extracting schema only to an XML workspace document.
import arcpy
arcpy.management.ExtractDataFromGeodatabase(
["Layer1", "Layer2"], "SCHEMA_ONLY", "XML_FILE", "",
r"C:\MyProject\MyXMLWkspDoc.xml")
ExtractDataFromGeodatabase example 3 (stand-alone script)
The following stand-alone Python script demonstrates how to use the ExtractDataFromGeodatabase function with multiple input datasets to an existing geodatabase using the Extent environment.
# Name: ExtractDataFromGeodatabase_Example3.py
# Description: Extract a subset of data by providing an extent using the Extent
# environment setting.
# Import system modules
import arcpy
# Set the current workspace (to avoid having to specify the full path to each
# input dataset)
arcpy.env.workspace = "C:\\MyProject\\MyData.gdb"
# Set the extent environment using the Extent class
arcpy.env.extent = arcpy.Extent(-107.0, 38.0, -104.0, 40.0)
# Set local variables
in_data = ["FC1", "FC2", "FC3"]
extract_type = "DATA"
out_type = "GEODATABASE"
out_geodatabase = "C:\\MyProject\\MyGDB.gdb"
out_xml = ""
out_folder_path = ""
out_name = ""
expand_fcs = "USE_DEFAULTS"
reuse_schema = "DO_NOT_REUSE"
get_related_data = "GET_RELATED"
extract_using_geom = ""
geom_filter = ""
all_records = "ALL_RECORDS_FOR_TABLES"
# Run ExtractDataFromGeodatabase
arcpy.management.ExtractDataFromGeodatabase(in_data,
extract_type,
out_type,
out_geodatabase,
out_xml,
out_folder_path,
out_name,
expand_fcs,
reuse_schema,
get_related_data,
extract_using_geom,
geom_filter,
all_records)
ExtractDataFromGeodatabase example 4 (stand-alone script)
The following stand-alone Python script demonstrates how to use the ExtractDataFromGeodatabase function to extract data to a new file geodatabase with a new coordinate system by using the Output Coordinate System environment.
# Name: ExtractDataFromGeodatabase_Example4.py
# Description: Extract data to use a new coordinate system by using the
# Output Coordinate System environment setting. Then run the tool a second
# time to load the data using the reuse_schema option
# Import system modules
import arcpy
# Set the Output Coordinate System environment
arcpy.env.outputCoordinateSystem = arcpy.SpatialReference("GCS_North_American_1983_HARN")
arcpy.env.geographicTransformations = "NAD_1983_HARN_To_WGS_1984_2"
# Set local variables
in_data = "C:/MyProject/MyGDB.gdb/FC1"
extract_type = "SCHEMA_ONLY"
out_type = "NEW_FILE_GEODATABASE"
out_geodatabase = ""
out_xml = ""
out_folder_path = "C:\\MyProject"
out_name = "MyOutputGDB.gdb"
expand_fcs = "USE_DEFAULTS"
reuse_schema = "DO_NOT_REUSE"
get_related_data = "GET_RELATED"
extract_using_geom = ""
geom_filter = ""
all_records = "SCHEMA_ONLY_FOR_TABLES"
# Run ExtractDataFromGeodatabase with the schema only option
arcpy.management.ExtractDataFromGeodatabase(in_data,
extract_type,
out_type,
out_geodatabase,
out_xml,
out_folder_path,
out_name,
expand_fcs,
reuse_schema,
get_related_data,
extract_using_geom,
geom_filter,
all_records)
# Rest the Output Coordinate System environment
arcpy.ClearEnvironment("outputCoordinateSystem")
arcpy.ClearEnvironment("geographicTransformations")
# Set variables that we are changing to load the data into the newly created schema in
# the different coordinate system.
extract_type = "DATA"
out_type = "GEODATABASE"
out_geodatabase = "C:\\MyProject\\MyOutputGDB.gdb"
out_folder_path = ""
out_name = ""
reuse_schema = "REUSE"
all_records = "ALL_RECORDS_FOR_TABLES"
# Run ExtractDataFromGeodatabase with the data and reuse schema option
arcpy.management.ExtractDataFromGeodatabase(in_data,
extract_type,
out_type,
out_geodatabase,
out_xml,
out_folder_path,
out_name,
expand_fcs,
reuse_schema,
get_related_data,
extract_using_geom,
geom_filter,
all_records)
ExtractDataFromGeodatabase example 5 (stand-alone script)
The following stand-alone Python script demonstrates how to use the ExtractDataFromGeodatabase tool and extracting schema into an XML file and then load data using the ImportXMLWorkspaceDocument tool.
# Name: ExtractDataFromGeodatabase_Example5.py
# Description: Extract schema of multiple feature classes and import the
# schema into an enterprise geodatabase
# Import system modules
import arcpy
# Set the current workspace (to avoid having to specify the full path to each input dataset)
arcpy.env.workspace = "C:\\MyProject\\MyData.gdb"
# Export the schema as an XML file from a feature class
result = arcpy.management.ExtractDataFromGeodatabase(
["FC1", "FC2"], "SCHEMA_ONLY", "XML_FILE", "",
"C:/MyProject/MyXMLWkspDoc.xml")
# Get the path to the output XML file
out_xml = result[0]
# Pass the output XML into the Import XML Workspace Document tool
arcpy.management.ImportXMLWorkspaceDocument("C:/MyProject/mySDEConnection.sde",
out_xml,
"SCHEMA_ONLY", "DEFAULTS")
ExtractDataFromGeodatabase example 6 (stand-alone script)
The following stand-alone Python script demonstrates how to use the ExtractDataFromGeodatabase tool to extract data to a new mobile geodatabase and create a domain for the new output geodatabase.
# Name: ExtractDataFromGeodatabase_Example6.py
# Description: Extract data and create a domain on output workspace
# Import system modules
import arcpy
# Export data to a new mobile geodatabase
result = arcpy.management.ExtractDataFromGeodatabase(
"C:/MyProject/mySDEConnection.sde/myGDB.USER1.FC1", "DATA", "NEW_MOBILE_GEODATABASE", "", "",
"C:/MyProject", "newMobileGDB")
# Get the path to the output mobile geodatabase
out_mobile_gdb = result[1]
# Pass the output geodatbase to the CreateDomain tool
arcpy.management.CreateDomain(out_mobile_gdb, "MyDomain", "My domain description", "SHORT", "CODED")