Show Navigation | Hide Navigation
You are here:
Geoprocessing tool reference > Data Management toolbox > General toolset > Tools

Merge (Data Management)

Release 9.3
Last modified March 8, 2012
E-mail This Topic Printable Version Give Us Feedback

Print all topics in : "Tools"


Related Topics

NOTE: This topic was updated for 9.3.1.


Combines input features from multiple input sources (of the same data type) into a single, new, output feature class. The input data sources may be point, line, or polygon feature classes or tables.


Illustration


Merge Illustration

Usage tips

Command line syntax
An overview of the Command Line window
Merge_management <inputs; inputs...> <output> {field_mappings}

Parameter Explanation Data Type
<inputs; inputs...>

The input point, line, or polygon feature classes or tables that will be merged together.

Table View
<output>

The output point, line, or polygon feature class or table that will contain all merged input features.

Feature Class | Table
{field_mappings}

The fields and field contents chosen from the inputs. Each of the unique input fields will be listed on the Field Map window, and when expanded, you will see a list of all the input field occurrences (subfields). New fields can also be added.

For each Field Map, you can add, rename, or delete output fields as well as set properties such as data type and merge rule. You can also delete an output field's subfields, and you can format any output field's values if the data type is text.

Learn more about choosing and setting the output fields.

Field Mappings
Data types for geoprocessing tool parameters


Command line example

Merge c:\gdb.mdb\Kauai_roads;c:\gdb.mdb\Honolulu_roads;c:\gdb.mdb\Maui_roads;c:\gdb.mdb\HawaiiCounty_roads c:\gdb.mdb\Hawaii_roads

Scripting syntax
About getting started with writing geoprocessing scripts
Merge_management (inputs, output, field_mappings)

Parameter Explanation Data Type
inputs (Required)

The input point, line, or polygon feature classes or tables that will be merged together.

Table View
output (Required)

The output point, line, or polygon feature class or table that will contain all merged input features.

Feature Class | Table
field_mappings (Optional)

The fields and field contents chosen from the inputs. Each of the unique input fields will be listed on the Field Map window, and when expanded, you will see a list of all the input field occurrences (subfields). New fields can also be added.

For each Field Map, you can add, rename, or delete output fields as well as set properties such as data type and merge rule. You can also delete an output field's subfields, and you can format any output field's values if the data type is text.

Learn more about choosing and setting the output fields.

Field Mappings

Data types for geoprocessing tool parameters


Script example

import arcgisscripting, sys
gp = arcgisscripting.create()

# Each of the input feature classes has an STFID, which is the
# combination of the Tract ID and Block ID for each block.  We
# want to separate these values out from this field into two new
# fields, TRACTID and BLOCKID.

gp.workspace = r"C:\Data\CityBlocks.mdb"
outfc = r"C:\Data\CityBlocks.mdb\AllBlocks"

# Create a fieldmappings and two new fieldmaps
fieldmappings = gp.createobject("FieldMappings")
fldmap_TRACTID = gp.createobject("FieldMap")
fldmap_BLOCKID = gp.createobject("FieldMap")

# List all the feature classes in the workspace that have the word
# block in their name and are of polygon feature type.
fcs = gp.listfeatureclasses("blocks*", "Polygon")
fc = fcs.next()

# Create a value table that will hold the input fc to Merge.
vt = gp.createobject("ValueTable")

while fc:
    # Adding a table is the fast way to load all the fields from the
    # input into fieldmaps held by the fieldmappings object.
    fieldmappings.AddTable(fc)

    # In this example we will also create two fieldmaps by 'chopping up'
    # an input field. We need to feed the field we are chopping up into
    # the new fieldmaps.
    fldmap_TRACTID.AddInputField(fc, "STFID")
    fldmap_BLOCKID.AddInputField(fc, "STFID")

    # Populate the input value table with feature classes.
    vt.AddRow(fc)

    fc = fcs.next()

# Set the starting and ending position of the fields going into the
# TractID fieldmap; this is the location in the STFID field where the
# TractID falls.
for x in range(0, fldmap_TRACTID.InputFieldCount):
    fldmap_TRACTID.SetStartTextPosition(x, 5)
    fldmap_TRACTID.SetEndTextPosition(x, 10)

# Set the Name of the Field output from this field map.
fld_TRACTID = fldmap_TRACTID.OutputField
fld_TRACTID.Name = "TRACTID"
fldmap_TRACTID.OutputField = fld_TRACTID

# Set the starting and ending position of the fields going into the
# BlockID fieldmap; this is the location in the STFID field where the
# blockID falls.
for x in range(0, fldmap_BLOCKID.InputFieldCount):
    fldmap_BLOCKID.SetStartTextPosition(x, 11)
    fldmap_BLOCKID.SetEndTextPosition(x, 16)

# Set the Name of the Field output from this field map.
fld_BLOCKID = fldmap_BLOCKID.OutputField
fld_BLOCKID.Name = "BLOCKID"
fldmap_BLOCKID.OutputField = fld_BLOCKID

# Add our custom fieldmaps into the fieldmappings object
fieldmappings.AddFieldMap(fldmap_TRACTID)
fieldmappings.AddFieldMap(fldmap_BLOCKID)

# Run the merge tool
gp.Merge(vt, outfc, fieldmappings)

Please visit the Feedback page to comment or give suggestions on ArcGIS Desktop Help.
Copyright © Environmental Systems Research Institute, Inc.