ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Merge

  • Summary
  • Illustration
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Combines multiple input datasets of the same data type into a single, new output dataset. This tool can combine point, line, or polygon feature classes or tables.

Use the Append tool to combine input datasets with an existing dataset.

Illustration

Merge tool

Usage

  • Use this tool to combine datasets from multiple sources into a new, single output dataset. All input datasets must be of the same type. For example, several point feature classes can be merged, or several tables can be merged, but a line feature class cannot be merged with a polygon feature class.

  • All fields in the output dataset and the contents of those fields can be controlled using the Field Map control.

    Learn more about mapping fields in scripts

  • This tool will not split or alter the geometries from the input datasets. All features from the input datasets will remain intact in the output dataset, even if the features overlap. To combine, or planarize, feature geometries, use the Union tool.

  • If feature classes are being merged, the output dataset will be in the coordinate system of the first feature class in the Input Datasets list, unless the Output Coordinate System geoprocessing environment is set.

  • This tool does not support annotation feature classes. Use the Append Annotation Feature Classes tool to combine annotation feature classes.

  • This tool does not support raster datasets. Use the Mosaic To New Raster tool to merge multiple rasters into a new output raster.

Syntax

Merge_management (inputs, output, {field_mappings})
ParameterExplanationData Type
inputs
[inputs,...]

The input datasets that will be merged together into a new output dataset. Input datasets can be point, line, or polygon feature classes or tables. The input datasets must all be of the same type.

Table View
output

The output dataset that will contain all combined input datasets.

Feature Class;Table
field_mappings
(Optional)

Controls how the attribute fields from the input datasets are mapped and transferred to the output dataset.

You can add, rename, or delete output fields as well as set properties, such as data type and merge rule.

Merge rules allow you to specify how values from two or more input fields are merged or combined into a single output value. There are several merge rules that determine how the output field is populated with values.

  • First—Use the input fields' first value.
  • Last—Use the input fields' last value.
  • Join—Concatenate (join) the input fields' values.
  • Sum—Calculate the total of the input fields' values.
  • Mean—Calculate the mean (average) of the input fields' values.
  • Median—Calculate the median (middle) of the input fields' values.
  • Mode—Use the value with the highest frequency.
  • Min—Use the minimum value of all input fields' values.
  • Max—Use the maximum value of all input fields' values.
  • Standard deviation—Use the standard deviation classification method on all input fields' values.
  • Count—Find the number of records included in the calculation.

You can use the ArcPy FieldMappings class to define this parameter.

Field Mappings

Code sample

Merge example 1 (Python window)

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

import arcpy
arcpy.env.workspace = "C:/data"
arcpy.Merge_management(["majorrds.shp", "Habitat_Analysis.gdb/futrds"], "C:/output/Output.gdb/allroads")
Merge example 2 (stand-alone script)

Use the Merge tool to move features from two street feature classes into a single dataset.

# Name: Merge.py
# Description: Use Merge tool to move features from two street
#                    feature classes into a single dataset with field mapping

# import system modules 
import arcpy
from arcpy import env

# Set environment settings
env.workspace = "C:/data"

# Street feature classes to be merged
oldStreets = "majorrds.shp"
newStreets = "Habitat_Analysis.gdb/futrds"

# Create FieldMappings object to manage merge output fields
fieldMappings = arcpy.FieldMappings()

# Add all fields from both oldStreets and newStreets
fieldMappings.addTable(oldStreets)
fieldMappings.addTable(newStreets)

# Add input fields "STREET_NAM" & "NM" into new output field
fldMap_streetName = arcpy.FieldMap()
fldMap_streetName.addInputField(oldStreets,"STREET_NAM")
fldMap_streetName.addInputField(newStreets,"NM")
# Set name of new output field "Street_Name"
streetName = fldMap_streetName.outputField
streetName.name = "Street_Name"
fldMap_streetName.outputField = streetName
# Add output field to field mappings object
fieldMappings.addFieldMap(fldMap_streetName)

# Add input fields "CLASS" & "IFC" into new output field
fldMap_streetClass = arcpy.FieldMap()
fldMap_streetClass.addInputField(oldStreets,"CLASS")
fldMap_streetClass.addInputField(newStreets,"IFC")
# Set name of new output field "Street_Class"
streetClass = fldMap_streetClass.outputField
streetClass.name = "Street_Class"
fldMap_streetClass.outputField = streetClass  
# Add output field to field mappings object
fieldMappings.addFieldMap(fldMap_streetClass)  

# Remove all output fields from the field mappings, except fields "Street_Class", "Street_Name", & "Distance"
for field in fieldMappings.fields:
    if field.name not in ["Street_Class","Street_Name","Distance"]:
        fieldMappings.removeFieldMap(fieldMappings.findFieldMapIndex(field.name))

# Since both oldStreets and newStreets have field "Distance", no field mapping is required

# Use Merge tool to move features into single dataset
uptodateStreets = "C:/output/Output.gdb/allroads"
arcpy.Merge_management([oldStreets, newStreets], uptodateStreets, fieldMappings)

Environments

  • Default Output Z Value
  • M Resolution
  • M Tolerance
  • Output XY Domain
  • Output Coordinate System
  • Extent
  • Current Workspace
  • Geographic Transformations
  • Scratch Workspace
  • Output has M values
  • Output has Z values
  • XY Resolution
  • XY Tolerance
  • Z Resolution
  • Z Tolerance
  • Output Z Domain
  • Output M Domain

Licensing information

  • ArcGIS for Desktop Basic: Yes
  • ArcGIS for Desktop Standard: Yes
  • ArcGIS for Desktop Advanced: Yes

Related topics

  • An overview of the General toolset

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal