Merge (Data Management) |
|
Release 9.3
Last modified March 8, 2012 |
![]() ![]() ![]() Print all topics in : "Tools" |
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
Usage tips
Use Merge when there are features from multiple input sources that need to be combined into one feature class.
Input data sources need not be adjacent; overlap is allowed.
The type of input data, such as polygons or tables, must be the same for all inputs.
If no coordinate system is specified in the Environment Settings, the output feature class will be in the coordinate system of the first feature class in the input features list.
Current map layers may be used to define input features. When using layers, only the currently selected features are used in the Merge operation.
Merge cannot use multiple input layers of the same name. Although ArcMap allows for the display of layers with the same name (from different directories) these may not be used in the Merge tool. For example, although c:\roads and d:\redlands\roads are two distinct datasets (located in different workspaces), both will appear in ArcMap with the same name (Roads).
Fields of type BLOB can only be passed into fields of type BLOB. BLOB field values can't be passed into any other data type.
Output fields and their contents can be controlled by the Field Map option.
The order in which you select fields determines the order in which their values will be displayed in the output field. When joining several input fields into a single output field, the output fields' values will be generated based on the order the input fields were chosen.
A new output field can be added to the output feature class or table composed of user-specified input fields.
A single output field can be generated from multiple input fields. This happens if more than one input feature class or table contains a field of the same name, or it can happen if a new field is created and the contents of the output field are generated from multiple (differently named) user-selected fields.
The first input feature classes' or tables' fields will appear first as subfields in the Field Map.
Merge identifies fields based on their name, not on their data type. Input fields are identified by their name and grouped into an output field of the same name.
The data type of an output field will default to the same as the data type of the first input field (of that name) it encounters. The data type may be changed manually at any time to any valid data type. All valid data types will be listed if the tools dialog box is used.
Merge does not perform edge matching. There will be no adjustment to the boundaries of features. Edge matching can be performed in ArcMap or ArcInfo Workstation only.
Unlike the Union function, Merge does not planarize the input features into a single output. Input features from all the input feature classes remain intact in the target feature class.
When performing a Join (Merge rule), you can specify your own delimiter such as a space, comma, period, or dash. If you want to use a space, make sure your mouse pointer is at the start of the input box and click the space bar once.
Concatenation can happen only if the fields chosen are from the same input feature class or table.
There are a number of Merge rules available: first, last, join, sum, mean, median, min, max, and standard deviation.
Format options are only available on input fields of type text (and in conjunction with the Join merge rule). You can specify start point, end point, and so on. Format allows you to apply your changes to the selected input field or to apply them to all occurrences of the same input field.
Standard deviation should not be performed on a single input because values can't be divided by zero, so standard deviation is not a valid option for single inputs. The Merge tool, however, will not fail if standard deviation is chosen for an output field that only has a single input field. In this instance, a value of zero (0) will be entered in the rows of the output field.
The following environment settings affect this tool: Extent and workspace.
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. |
Field Mappings |
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. |
Field Mappings |
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)