Extract Data By Feature (Topographic Production)

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})
ParameterExplanationData 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:

  • Dataset—Extracts the schema of the dataset to the child workspace
  • Rows Option—Specifies whether to extract all rows, schema only, or by filtering criteria.
    • All Rows—Extracts all rows of the dataset to the child workspace.
    • Schema Only—Extracts the schema of the dataset to the child workspace.
    • Use Filters—If a feature layer is specified for the Filter Feature Layer parameter, the tool extracts features that either intersect or are contained by features in the Filter Feature Layer.
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.

  • REUSEThe schema is reused.
  • DO_NOT_REUSEThe schema is not reused. This is the default.
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.

  • INTERSECTSFeatures in the Input Datasets parameter that intersect features in the Filter Feature Layer parameter will be extracted.
  • CONTAINSFeatures in the Input Datasets parameter that are contained by the selected feature in the Filter Feature Layer parameter will be extracted.
  • CLIPFeatures in the Input Datasets parameter that intersect features in the Filter Feature Layer parameter will be extracted, and the features will be split at the AOI boundary and only those within the AOI will be kept.
String
checkout_replica
(Optional)

Specifies whether the data will be checked out, replicated, edited, and checked back in one time.

  • CHECKOUT_REPLICAThe replica will be checked out.
  • DO_NOT_CHECKOUT_REPLICAThe replica will not be checked out. This is the default.
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.

  • USE_DEFAULTSThe expanded feature classes and tables related to the feature classes and tables in the replica will be added. The default for feature classes is to replicate all features intersecting the spatial filter. If no spatial filter has been provided, all features are included. The default for tables is to replicate the schema only.
  • ADD_WITH_SCHEMA_ONLYOnly the schema for the expanded feature classes and tables will be added.
  • ALL_ROWSAll rows for expanded feature classes and tables will be added.
  • DO_NOT_ADDNo expanded feature classes and tables will be added. This is the default.
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.

  • DO_NOT_GET_RELATEDRelated data will not be replicated. This is the default.
  • GET_RELATEDRelated data will be replicated.
String

Derived Output

NameExplanationData Type
updated_target_gdb

The updated target geodatabase.

Workspace; GeoDataServer

Code sample

ExtractDataByFeature example (stand-alone script)

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

This tool does not use any geoprocessing environments.

Licensing information

  • Basic: No
  • Standard: Requires Production Mapping
  • Advanced: Requires Production Mapping

Related topics