Merge

This topic covers the Merge interactive editing command used to interactively combine areas, lines, or points.  

 

 

The Merge command combines an existing area, line, or point with other areas, lines, or points in the same layer, merging field values as desired into the resulting single object.  Merge is available in the right-click context menu for editing when an existing point, line, or area is picked with an alt-click.  By default, Merge combines the picked object with selected objects.   For example, select some areas to be merged, and then Alt-click an existing area to pick it, and then right-click and choose Merge to combine the selected areas into the picked area.  

 

Options:

 

 

See also the Newsflash - Merge, Clip, and Split video.

Example

Merge makes it easy to combine multiple areas, lines, or points interactively into one area, line or point.  In the illustrations below we have two areas adjacent to the Massachusetts coast, a blue area and a purple area, that we want to combine into one area.  The example uses example areas from the beginning of the Clip topic.   We want the new area to inherit fields from the blue area. The blue area will be the picked area, taking precedence in the merge operation.

 

Start by Ctrl-clicking any areas to be combined with the picked area.   Next, alt-click to pick the area that will take precedence in the merge.

 

 

Right-clicking anywhere and choosing Merge by default will pop open a Merge dialog to allow us to choose how to combine attributes.  Pressing OK will merge the picked area with all selected objects to create a single, new area.

 

 

The new area exactly merges the blue area with the selected purple area, and clears the picked status of the area.

 

Merge by default takes attributes from the picked, blue area.  If we would like to merge attributes in different ways, for example, summing a population field in both areas to get a combined result that is the sum of populations, we can do that in the Merge dialog that pops open.  Choices we make for merging attributes will persist until changed again, to make repetitive operations fast and easy.

Summary

Editing with Merge uses a simple workflow: select objects to be merged into the picked object, pick the primary object, and apply the merge.  

 

Merge a picked area with other areas:

 

  1. Ctrl-click to select the areas that will be merged into the picked area.

  2. Alt-click the primary area to pick it.

  3. Right-click anywhere in the map window and choose Merge.

  4. In the Merge dialog that pops open, choose rules for merging attributes.  The defaults will copy fields from the picked, primary area.

  5. By default, only selected areas will be merged into the picked area.  Uncheck the Use selection only box, if desired, to merge all areas in the layer into the picked object.

  6. Press OK to apply the merge.    Press Cancel to abandon the merge.    

 

 Pressing OK is a command to apply the merge and cannot be undone.

 

When merging selected objects into the picked object the picked object can be selected, but does not need to be selected.

 

The workflow above works exactly the same way when merging lines and points.   The result of merging points will be a multipoint, a branched point object that looks like separate point objects, but which in reality is a single point object.

Example: Merging Areas

We will merge North Carolina and South Carolina into a single state, automatically summing the populations.

 

 

We begin with a  Map with a drawing layer of states in the US and a labels layer providing the name of each state and the 1 July 2020 population of that state according to Wikipedia.

 

 

Opening the table for the states drawing, we see a Population field for each state in addition to the Name field.  The Color field is a random number used to thematically format the state's area fill color.   

 

Creating Labels

The Labels layer is created from the States drawing.

 

In the Project pane, right-click onto the States drawing and in the context menu choose Create - New Labels.

 

 

In the New Labels dialog, choose <pattern> for the Text.  This enables the text pattern pane for editing, allowing us to specify a more sophisticated label text pattern than simply choosing one field as the source of the label text.

 

 

Change the text pattern to:

 

[Name]

   Pop: [Population]

 

That uses both the Name field and the Population field.  See the Label Text topic for how to use field names to create text for labels.   See also the Create Labels from Multiple Fields section of the Labels topic.

 

Press Create Labels.   That creates a new labels component, which can be dragged and dropped into the map.

Merging

In our scenario, we pretend North Carolina will annex South Carolina, so that except for the Population field we want the merged object to inherit fields like Name and Color from North Carolina.  North Carolina will be the picked area into which we will merge the South Carolina area.

 

 

With the focus on the States layer tab, we Ctrl-click South Carolina to select it.

 

 

South Carolina immediately redraws in red selection color.   We Alt-click North Carolina to pick it.

 

 

That picks North Carolina, putting it into Values mode in the Info pane so we can see the values of attributes it contains, and changing the path outlining the area into picked mode, with small blue squares at vertices defining the path.

 

We right-click anywhere in the map to launch the context menu for picked objects.

 

 

Choose Merge to launch the Merge dialog.

 

 

In the Merge dialog, double-click into the copy rule for the Population field, and choose sum as the rule.   This will sum the Population field for both states as the value for the Population field for the merged result.   The other fields will simply copy the values from the picked North Carolina area.

 

 

Press Cancel to abandon the merge and not make any changes.

 

Press OK to commit the merge, merging South Carolina into North Carolina.

 

 

The result is that the former geometry of South Carolina has been merged into North Carolina, growing the North Carolina area, while the South Carolina area no longer exists.

 

 

In the States Table we see that North Carolina is still in the same record, but with the Population field increased by the population of South Carolina. The mfd_id, Name, FIPS, and Color fields have all been inherited from the original picked object, North Carolina.  

 

If we searched the table we would see that the record for South Carolina no longer exists, since South Carolina has been merged into the new, expanded, North Carolina object.

 

In the example above, we merged a single, adjacent area, South Carolina, into the North Carolina area.   Merge also works to merge more than one area, and can handle a combination of areas being merged that are adjacent or not adjacent.

 

 

For example, we can continue this example by Ctrl-clicking the areas for Mississippi, Georgia and Florida to select them, Alt-clicking our new North Carolina area to pick it, and then right-clicking and choosing Merge.  

 

 

The Merge dialog remembers our prior settings for this drawing's fields, so sum is already loaded as the desired merge method for the Population field.  

 

Press OK.

 

 

The result is that the North Carolina area grows to cover all the regions of the states merged into it.   What appears to be a separate object, the former Mississippi region, is part of the North Carolina area, which, in addition to the branches that showed various small barrier islands along the coastline, now has the former Mississippi region as a large branch.  

 

The population for North Carolina is the sum of populations from the previous merge, plus populations from Mississippi, Georgia, and Florida.   Other attribute fields, such as mfd_id, Name, FIPS, and Color fields have all been inherited from the original picked object, North Carolina, so that the color for the new, merged North Carolina is the same.

 

The records for Mississippi, Georgia, and Florida disappear from the table, since those areas no longer exist, having been merged into North Carolina.

 

Merge always merges into the picked object.   That can be any object we pick.

 

 

For example, suppose we Ctrl-click the merged North Carolina area to select it, we Alt-click Alabama to pick it, and then we right-click to choose Merge.

 

 

Merge rules still remember that we want to sum populations.   However, now, the rules apply to the picked object, Alabama, meaning that fields that are copied will be copied from Alabama.

 

Press OK.

 

 

The result is a new object that merges the big, multibranched, selected North Carolina area into the picked Alabama area.  

 

 

The North Carolina area has disappeared from the table, since it has been merged into the Alabama area.   The Alabama area inherits previous attribute field values except for Population, which has increased to include the population value from the North Carolina area.

Example: Merging Lines

The same workflow used for merging areas works for merging lines:  select lines to be merged into the picked line, alt-click a line to pick it, and then right-click and choose Merge.

 

We will merge highway segments into a single line.

 

 

The example above shows highways (autoroutes) in France downloaded from the Route500 data set at the French cadastral agency IGN website.   We would like to work with the A11 autoroute near Chartres, but we find it inconvenient that it is made up of multiple line objects.

 

For example, if we ctrl-click part of the A11 autoroute near Chartres, we see that only a small portion of it is selected, since the A11 autoroute is represented by many line objects arranged end to end.

 

 

If we pop open the drawing's table, we see that this particular line segment is 11.97 kilometers long (longueur) and has A11 as the route number in the NUM_ROUTE field.   We would like to merge the A11 line objects in the vicinity of Chartres. together into a single line object, to facilitate our cartography in the vicinity of Chartres.

 

We begin by drawing a selection box using Ctrl-click and drag to select all of the A11 segments in the vicinity of Chartres.

 

 

We then Alt-click the segment near Chartres to pick it.

 

 

We then right-click anywhere in the map and choose Merge.   Note that it is OK that the line which we picked with an Alt-click was also selected along with all of the other line objects that will be merged into it.  

 

 

In the Merge dialog, we leave the merge rules as is for all attributes except for the LONGUEUR (length) field.  For that field we change the rule to sum, so the lengths of all the line objects being joined will be summed.

 

Press OK.

 

 

The result is a single line object, which we can see by  Ctrl-clicking anywhere on the new line to see the entire line is selected in red selection color.

 

 

Scrolling down to the selected record in the drawing's table, we see that the fields are the same, except for the LONGUEUR field, which is now 93.97 kilometers.

 

 

Another way to see all the lines that were selected have been merged into a single line is to Alt-click anywhere on the line to pick it.  It immediately is drawn in picked mode, showing small blue boxes at every vertex of the line.

 

This example merged only line objects in the vicinity of Chartres.   If we wanted, we could use similar workflow to merge all of the A11 segments for all of France into a single line, by first using the Select pane to select all lines with A11 in their NUM_ROUTE field, and then doing the merge as above.  

Transfer Rules for Merge

Transfer rules for Merge are similar to those used for joins.

 

 

Transfer rules available depend on the data type of the field, as follows:

 

(none)

Use the value in the picked object.  Available for any data type.

average

Use  the average of values in the objects being merged.  Available for any numeric type.

copy

Use the value in the picked object if it is not NULL.  If it is NULL, then use the first non-NULL value that is encountered from one of the merged objects.    Available for any data type.

maximum

Use the largest value in the objects being merged.  Available for any data type except binary.

minimum

Use the smallest value in the objects being merged.    Available for any data type except binary.

sum

Use the sum of values in the objects being merged.  Available for any numeric type.

 

Computed fields and unique fields (fields that have a btree index requiring unique values) are carried over from the picked object and will be grayed out in the Merge dialog, since transfer rule cannot be specified for such fields.  Computed fields will be recomputed.

 

Notes

Blue color used in editing - Objects that are picked for editing, as well as paths drawn by the measurement tool and in editing, have their coordinate edit handles and boundaries shown using the same blue color used for previews and for provisional edits in other settings. If desired, we can change the preview and provisional color used by Manifold in the Tools - Options dialog.   This allows us to use a color different than blue color in cases where a visual display already uses very much blue color or to provide a more discernible color in case of color blindness.

 

Permissions - To use Merge, the drawing's table must support updating and deleting records.  That means, of course, we cannot use merge on drawings stored in read-only data sources or in databases where our user role does not have the ability to update and delete records in the drawing's table.

 

Curves and Z removed - Curvilinear segments and Z values are removed from results.

 

Progress and canceling - The Merge command shows a progress bar and allows canceling.  That allows using Merge with big data sets or with data sets on slow data sources.

 

Multipoints - Using Merge to combine points into a picked point results in a multipoint.   Multipoints are generally a bad idea.  See the discussion in the Notes at the end of the Editing Drawings topic.

 

 

Videos

5 Minute Tutorial - Editing with Clip

 

Newsflash - Merge, Clip, and Split

 

See Also

Getting Started

 

User Interface Basics

 

Drawings

 

Snap Modes

 

Clip

 

Erase

 

Split

 

Measurements

 

Copy and Paste between Drawings or Tables

 

Layers Pane

 

Info Pane

 

Example: Draw Lines, Areas and Points - Simple example of using basic mouse moves to add points, lines and areas to a drawing.

 

Example: Trace an Area in a Map over an Image Background - In a map with a drawing layer above an image layer, create an area object in the drawing by tracing over the outlines of something seen in the image layer below.

 

Example: Edit Coordinates While Creating an Object - When creating an object in a map using a tool such as Create Area, right in the middle of the process we can edit coordinates in the Info pane Coordinates tab.   This example shows the step by step process.

 

Example: Change the Shape of Areas - Step-by-step editing of an existing area in a drawing: changing the shape by moving a vertex, by moving several vertices together, by moving the entire object, by deleting a vertex and by adding a vertex.

 

Example: Add Vertices in the Middle of a Line being Created - During the creation of a new object we can go back and make corrections, additions and deletions to coordinates already marked.  In this example we start creating a new line, and then notice we have skipped over some locations we wanted to click.  We go back to add those vertices (coordinates), and then we continue with creating the line.

 

Videos

Editing Drawings - Create Areas - How to create areas (polygons) in a drawing.  We digitize a lake by tracing over a background satellite image layer from a web server.  This quick video shows how editing tools in Manifold make it easy to digitize objects very quickly, correcting any errors with no stress or fear of getting it wrong.  Includes a quick demo of snapping.

 

Editing Drawings - Create Lines with Curves - A very short video showing how to create lines in drawings using straight segments and also circular arcs.  We create a line in a map of Paris showing our walk around circular ponds. Manifold can create polylines using straight line segments for classic polylines, or using curved segments that are circular arcs, ellipses, or splines for very smooth curves, a much faster and easier technique than clicking many points.  Super!