Merge Layers (GeoAnalytics)

Summary

Combines feature layers to create a single output layer.

The tool requires that both inputs have the same geometry type (point, line, or polygon) or be tables. If time is enabled on one layer, the other layer must also be time enabled and have the same time type (instant or interval). The result will always contain all fields from the input layer. All fields from the merge layer will be included by default, or you can specify custom merge rules to define the resulting schema. The following are examples:

  • You have three layers representing the administrative boundaries of England, Wales, and Scotland and want a single layer of Great Britain. You can use Merge Layers to combine the areas and maintain all fields from each area.
  • You have two layers containing parcel information for contiguous townships. You want to merge them into a single layer, keeping only the fields that have the same name and type in the two layers.

Illustration

Merge Layers workflow diagram
The Merge Layers workflow diagram is shown.

Usage

  • Both inputs must have the same geometry type (point, line, or polygon) or be tables.

  • Both inputs must have the same time type (instant or interval) or not be time enabled.

  • By default, all fields from both inputs will be copied to the output. Optionally, you can rename, remove, or match the fields from the merge layer to the input layer.

    OperationDescriptionExample

    Rename

    The field will be renamed in the output. A text box will appear where you can specify the new name.

    You want to merge two layers, each with a field called COUNT. This field represents a count of individuals in one layer and a count of families in the other. The two COUNT fields will be merged by default because they have a matching field name. Use Rename to change the name of the field in the merge layer to MERGE_COUNT to keep the two fields separate in the result layer.

    Remove

    The field will be removed from the output.

    You want to merge two layers but don't want to preserve some fields in the merge layer, such as OBJECTID. Use Remove to prevent those fields from being written to the result layer and keep only fields of interest.

    Match

    The field names are made equivalent. Values of the field from the layer to merge will be copied to the matched output field.

    You want to merge two tabular layers of survey results. The input layer has a field called Name that contains the names of survey participants. An equivalent field in the merge layer is called Participant. Use Match to indicate that these fields are equivalent, and both will be merged into a single field called Name in the result layer.

  • If the input layer and merge layer contain fields with matching names but mismatched field types, the tool will fail unless the two field types can be successfully merged. If the input field is string and the merge field is numeric, the fields will be merged into a single string field in the output layer. If the input field is a double and the merge field is numeric, the fields will be merged into a single double field in the output layer. In all other cases, Merging Attributes must be used to rename or remove one of the matching fields to run the tool.

  • You can improve the performance of the Merge Layers tool by doing one or both of the following:

    • Set the extent environment so that you only analyze data of interest.
    • Use data that is local to where the analysis is being run.

  • This geoprocessing tool is powered by ArcGIS GeoAnalytics Server. Analysis is completed on your GeoAnalytics Server, and results are stored in your content in ArcGIS Enterprise.

  • When running GeoAnalytics Server tools, the analysis is completed on the GeoAnalytics Server. For optimal performance, make data available to the GeoAnalytics Server through feature layers hosted on your ArcGIS Enterprise portal or through big data file shares. Data that is not local to your GeoAnalytics Server will be moved to your GeoAnalytics Server before analysis begins. This means that it will take longer to run a tool, and in some cases, moving the data from ArcGIS Pro to your GeoAnalytics Server may fail. The threshold for failure depends on your network speeds, as well as the size and complexity of the data. Therefore, it is recommended that you always share your data or create a big data file share.

    Learn more about sharing data to your portal

    Learn more about creating a big data file share through Server Manager

Parameters

LabelExplanationData Type
Input Layer

The point, line, or polygon features or table to merge with the merge layer.

Record Set
Merge Layer

The point, line, or polygon features or table to merge with the input layer. The merge layer must contain the same feature type and time type as the input layer.

Record Set
Output Name

The name of the output feature service.

String
Merging Attributes
(Optional)

A list of values that describe how fields from the merge layer are to be modified and matched with fields in the input layer. All fields from the input layer will be written to the output layer. If no merging attributes are defined, all fields from the merge layer will be written to the output layer.

If a field exists in one layer but not the other, the output layer will still contain two fields. The output field will contain null values for the input features that did not have the field. For example, if the input layer contains a field named TYPE but the merge layer does not contain TYPE, the output will contain TYPE, but its values will be null for all the features copied from the merge layer.

You can control how fields in the merge layer are written to the output layer using the following merge types:

  • Remove—The merge layer field will be removed from the output layer.
  • Rename—The merge layer field will be renamed in the output. You cannot rename a field from the merge layer to a field from the input layer. To make field names equivalent, use the match option.
  • Match—The merge layer field is renamed and matched to a field from the input layer. For example, the input layer has a field named CODE and the merge layer has a field named STATUS. You can match STATUS to CODE, and the output will contain the CODE field with values of the STATUS field used for features copied from the merge layer. Type casting is supported for numeric values. Matching numeric fields to string fields is not supported.

Value Table
Data Store
(Optional)

Specifies the ArcGIS Data Store where the output will be saved. The default is Spatiotemporal big data store. All results stored in a spatiotemporal big data store will be stored in WGS84. Results stored in a relational data store will maintain their coordinate system.

  • Spatiotemporal big data store —Output will be stored in a spatiotemporal big data store. This is the default.
  • Relational data store —Output will be stored in a relational data store.
String

Derived Output

LabelExplanationData Type
Output

The output layer containing the combined features and attributes from both the input and merge layers.

Record Set

arcpy.geoanalytics.MergeLayers(input_layer, merge_layer, output_name, {merging_attributes}, {data_store})
NameExplanationData Type
input_layer

The point, line, or polygon features or table to merge with the merge layer.

Record Set
merge_layer

The point, line, or polygon features or table to merge with the input layer. The merge layer must contain the same feature type and time type as the input layer.

Record Set
output_name

The name of the output feature service.

String
merging_attributes
[[Merge Field, Action, Input Field],...]
(Optional)

A list of values that describe how fields from the merge layer are to be modified and matched with fields in the input layer. All fields from the input layer will be written to the output layer. If no merging attributes are defined, all fields from the merge layer will be written to the output layer.

If a field exists in one layer but not the other, the output layer will still contain two fields. The output field will contain null values for the input features that did not have the field. For example, if the input layer contains a field named TYPE but the merge layer does not contain TYPE, the output will contain TYPE, but its values will be null for all the features copied from the merge layer.

You can control how fields in the merge layer are written to the output layer using the following merge types:

  • Remove—The merge layer field will be removed from the output layer.
  • Rename—The merge layer field will be renamed in the output. You cannot rename a field from the merge layer to a field from the input layer. To make field names equivalent, use the match option.
  • Match—The merge layer field is renamed and matched to a field from the input layer. For example, the input layer has a field named CODE and the merge layer has a field named STATUS. You can match STATUS to CODE, and the output will contain the CODE field with values of the STATUS field used for features copied from the merge layer. Type casting is supported for numeric values. Matching numeric fields to string fields is not supported.

Value Table
data_store
(Optional)

Specifies the ArcGIS Data Store where the output will be saved. The default is SPATIOTEMPORAL_DATA_STORE. All results stored in a spatiotemporal big data store will be stored in WGS84. Results stored in a relational data store will maintain their coordinate system.

  • SPATIOTEMPORAL_DATA_STOREOutput will be stored in a spatiotemporal big data store. This is the default.
  • RELATIONAL_DATA_STOREOutput will be stored in a relational data store.
String

Derived Output

NameExplanationData Type
output

The output layer containing the combined features and attributes from both the input and merge layers.

Record Set

Code sample

MergeLayers example (Python window)

The following Python window script demonstrates how to use the MergeLayers tool.

#-------------------------------------------------------------------------------
# Name: MergeLayers.py
# Description: Merge two layers containing parcel information.
#
# Requirements: ArcGIS GeoAnalytics Server

# Import system modules
import arcpy

# Set local variables
inputFeatures = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/parcels_west/FeatureServer/0"
mergeFeatures = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/east_parcels/FeatureServer/0"
mergingAttributes = [["CODE", "MATCH", "ID"], ["globalid", "REMOVE"]]
outFS = "all_parcels"
dataStore = "SPATIOTEMPORAL_DATA_STORE"

# Execute Merge Layers
arcpy.geoanalytics.MergeLayers(inputFeatures, mergeFeatures, outFS, 
                               mergingAttributes, dataStore)

Environments

Output Coordinate System

The coordinate system that will be used for analysis. Analysis will be completed in the input coordinate system unless specified by this parameter. For GeoAnalytics Tools, final results will be stored in the spatiotemporal data store in WGS84.

Licensing information

  • Basic: Requires ArcGIS GeoAnalytics Server
  • Standard: Requires ArcGIS GeoAnalytics Server
  • Advanced: Requires ArcGIS GeoAnalytics Server

Related topics