Summary
Extracts features from multiple input feature classes into a target database.
This tool can extract all features, the schema only, or features that match a filter. Features can be filtered based on a polygon feature. The Target Geodatabase parameter can be a database containing input schema, or it can be an empty database in which the tool will create a schema that matches the input dataset.
Usage
Input Datasets can include points, polylines, polygons, and annotation features.
If the input features include a topology, features are extracted from all the layers that participate in that topology. This may be in addition to the layers specified in Input Datasets.
The extracted data will use the same names as the data provided for Input Datasets.
All Input Datasets must originate from the same workspace. For example, if extracted data originates from a feature dataset, the tool will create a feature dataset of the same name in the target geodatabase.
The target geodatabase must exist before you run this tool.
The Re-use Schema parameter is enabled for file geodatabases only.
The Filter Feature Layer parameter requires that one feature is selected.
The selected feature in the Filter Feature Layer parameter must be a polygon. If it is not, the tool will return an error.
If the target geodatabase is a Microsoft SQL Server Express database and some of the input datasets are open in ArcGIS Pro, the extraction may fail due to schema locks.
If a replica with the same name already exists in either the source or target geodatabase, the tool will abort the operation with an error message.
If you are creating a checkout replica, the input datasets must be registered as versioned.
Web feature services are not supported for extraction at this time.
Enterprise databases are not supported as a Target Geodatabase at this time.
Syntax
ExtractDataByFeature(in_datasets, target_gdb, {reuse_schema}, {filter_feature}, {filter_type}, {checkout_replica}, {replica_name}, {expand_feature_classes_and_tables}, {get_related_data})
Parameter | Explanation | Data Type |
in_datasets [[Dataset, Rows Option],...] | A value table of rows that contain a dataset to extract and a filter option for that dataset. Specifying a filter option allows you to control how rows are replicated in each dataset. The following are filter options:
| Value Table |
target_gdb | The workspace into which data will be extracted. | Workspace; GeoDataServer |
reuse_schema (Optional) | Specifies whether to reuse a geodatabase that contains the schema of the data you want to extract. This reduces the amount of time required to extract the data. This option is only supported for file geodatabases.
| Boolean |
filter_feature (Optional) | A feature layer with one selected feature used to limit the extent of the data that will be extracted. | Feature Layer |
filter_type (Optional) | Specifies the spatial relationship between Filter Feature Layer and Input Datasets using Intersects, Contains, or Clip. The spatial relationship is applied to data in an extent defined by the area of interest (AOI) specified in the Filter Feature Layer parameter.
| String |
checkout_replica (Optional) | Specifies whether the data will be checked out, replicated, edited, and checked back in one time.
| Boolean |
replica_name (Optional) | The name of the replica to check out. | 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.
| String |
get_related_data (Optional) | Specifies whether rows related to existing rows in the replica will be replicated. For example, consider a feature (f1) inside the replication filter and a related feature (f2) from another class outside the filter. Feature f2 is included in the replica if you choose to get related data.
| String |
Derived Output
Name | Explanation | Data Type |
updated_target_gdb | The updated target geodatabase. | Workspace; GeoDataServer |
Code sample
The following stand-alone script demonstrates how to use the ExtractDataByFeature tool to extract features from an input feature class into a target file geodatabase.
# Name: ExtractDataByFeature_sample.py
# Description: Extracts features from an input feature class into a target file geodatabase.
# Import System Modules
import arcpy
# Check Out Extensions
arcpy.CheckOutExtension('Foundation')
# Making AOI Feature Layer
Index = r'C:\Data\ReferenceData\MapIndex.gdb\MapIndex\TLM50_Index'
arcpy.management.MakeFeatureLayer(Index, "TLM50_Index")
# Selecting a single AOI from the AOI feature layer
selection_string = "NRN = 'V795X16573'"
arcpy.management.SelectLayerByAttribute("TLM50_Index", "NEW_SELECTION", selection_string)
# Setting Local Variables
in_datasets = r'C:\Data\TDS_7.gdb\TDS\StructurePnt'
target_gdb = r'C:\Data\ExtractTest.gdb'
reuse_schema = "DO_NOT_REUSE"
filter_feature = "TLM50_Index"
filter_type = "CONTAINS"
checkout_replica = "DO_NOT_CHECKOUT_REPLICA"
replica_name = ''
expand_feature_classes_and_tables = 'DO_NOT_ADD'
get_related_data = 'DO_NOT_GET_RELATED'
# Calling the Extract Data By Feature tool to extract Structure Point features to a target file geodatabase
arcpy.topographic.ExtractDataByFeature(in_datasets, target_gdb, reuse_schema, filter_feature, filter_type, checkout_replica, replica_name, expand_feature_classes_and_tables, get_related_data)
# Getting all messages, warnings, and errors from the tool run and printing the results back to the user
messages = arcpy.GetMessages(0)
warnings = arcpy.GetMessages(1)
errors = arcpy.GetMessages(2)
arcpy.AddMessage('Tool Messages: {}\nTool Warnings: {}\nTool Errors{}\n'.format(messages, warnings, errors))
# Check In Extensions
arcpy.CheckInExtension('Foundation')
Environments
Licensing information
- Basic: No
- Standard: Requires Production Mapping
- Advanced: Requires Production Mapping