Transform - Geometry: Merge

The Merge template appears in the template list when a geometry field, of type geom, geommfd, or geomwkb, has been picked in the Transform pane.   It merges multiple objects into one, optionally grouping by an attribute field.

 

Merge

Combine objects, optionally grouping by an attribute field, and save the combined result into the specified Result destination using the specified geometry type.   Objects to be merged optionally can be grouped by a field given in the Group box.   Options in the Merge into box are:

 

  • area (dissolve) - For areas only, a classic GIS "dissolve" operation by field values when grouped by a field or simply a union of all areas into one area when not grouped by a field.
  • center - A merge into the center point of a minimum enclosing circle, either one center point for all objects together or into multiple center points for minimum enclosing circles of merged groups of objects when objects are grouped by a field,.  
  • center inner (area) - For areas only, a merge into the center point of a minimum enclosing circle as adjusted to fall within the original area, either one center point for all areas together or into multiple center points for minimum enclosing circles of merged groups of areas when areas are grouped by a field.   
  • center weight (area) - For areas only, a merge into the center of gravity point of the subject areas, as if they were cut out of cardboard, either one center point for all areas together or into multiple center of gravity points for merged groups of areas when areas are grouped by a field.  
  • circle - A merge into a minimum enclosing circular (in the coordinate system of the drawing) area,  either one circular area for all objects together or into multiple circular areas of merged groups of objects when objects are grouped by a field,.
  • convex hull - A merge into a convex hull area,  either one convex hull for all objects together or into multiple convex hulls for  merged groups of objects when objects are grouped by a field.
  • line - For lines only, a merge into a single, branched line object for all lines together, or into multiple, possibly branched lines for merged groups of lines when lines are grouped by a field.
  • points - For points only, a merge into a single, branched point object for all points together, or into multiple, possibly branched points for merged groups of points when points are grouped by a field.
  • rectangle - A merge into a minimum enclosing rectangular area aligned north-south, either one rectangle for all objects together or into multiple rectangles of merged groups of objects when objects are grouped by a field.
  • rectangle with rotation - A merge into an enclosing rectangular area freely rotated to whatever bearing alignment allows the smallest enclosing rectangle, either one rectangle for all objects together or into multiple rectangles of merged groups of objects when objects are grouped by a field.

 

The center operations when the mfd_id field is used for grouping are equivalent to the Center transform, since simply a centroid of the desired sort is created for each object.  

 

Whenever a circle is mentioned in the above, that is a circular figure within the coordinate system of the drawing, or an approximation of a circle in radial coordinate systems like Latitude / Longitude.  Use a linear coordinate system that preserves measurement of distance in the region of interest to generate "real" circles.

 

Creating branched point objects using the points option is generally a very bad idea, because the result is something that looks like independent point objects but which in fact is a single, branched object, a so-called "multipoint."   Friends do not let friends create multipoints.

 

Launch the template by choosing a geometry field and then double-clicking the Merge template.  When the template launches we can specify options.

 

 

Merge : area (dissolve)

Take areas in the source geometry field and merge them into a single area, with branches for each of what originally were non-contiguous, separate areas and place the result into the specified Result destination.   Lines and points are ignored.   

 

The Merge : area (dissolve) operation provides a Group option to specify a field that can be used for grouping the merge, to provide a classic GIS dissolve operation based on a field.   When a field is specified, all areas with the same value in that field will be merged into the same area.

 

See the Example: Merge : areas (dissolve) topic for examples.

Example

We start with the sample drawing with three areas, two lines and two points.

 

 

Opening the drawing's table we can see records for the areas, lines and points.

 

With the focus on the drawing, in the Transform pane we choose the Geom field and then we choose the Merge template.

 

 

In the Merge template we choose the area (dissolve) operation.  We leave the Group option at the default (no field) setting, which will merge all areas in the drawing into a single area.  

 

We choose New Table and specify Merged Objects areas for the name of the new drawing and an analogous name for the new table.   Press Transform.

 

A new Merged Objects areas drawing appears in the Project pane.  We drag and drop the new Merged Objects areas drawing as a layer into the Objects Drawing window.   

 

 

The drawing has what appears to be three areas in it, but we know that these are all part of a single area object.   What appear to be three areas are really a single area object that has three branches.    Opening the new drawing's table we see it has one record.  

 

We Ctrl-click any of the areas in the drawing, to demonstrate they are all part of one area object.

 

 

Ctrl-clicking any of the areas selects all of them, proving they are all part of the same, single area object.   

Example

We start with an example drawing with four areas, styled with transparent fill color so we can see where area objects overlap..   Three of the areas are smaller areas.  One larger area overlaps the other three areas.

 

 

Opening the drawing's table we can see four records for the four areas in the drawing.

 

 

With the focus on the Misc Areas Drawing, in the Transform pane we choose the Geom field and then we choose the Merge template.

 

 

In the Merge template we choose the area (dissolve) operation.  We leave the Group option at the default (no field) setting, which will merge all areas in the drawing into a single area.  

 

We choose New Table and specify Misc Areas merged for the name of the new drawing and an analogous name for the new table.   Press Transform.

 

A new Misc Areas merged drawing and table appear in the Project pane.  We drag and drop the new Misc Areas merged drawing as a layer into the Misc Areas Drawing window.   

 

 

The new Misc Areas merged drawing shows one area created by merging the four previous areas.  All regions of intersection have been blended into the single area object.

 

 

Opening the new  Misc Areas merged Table,  we see it has one record.

Merging Selected Areas

Checking the Transform selection only box allows us to merge only selected areas.

 

 

Suppose we first select two areas and then run the area (dissolve) operation as before, but this time we check the Transform selection only box.

 

In the Merge template we choose the area (dissolve) operation.  We leave the Group option at the default (no field) setting, which will merge all areas in the drawing into a single area.  

 

We choose New Table and specify Misc Areas merged selection for the name of the new drawing and an analogous name for the new table.   

 

Check the Transform selection only box and press Transform.

 

A new Misc Areas merged selection drawing and table appear in the Project pane.  We drag and drop the new Misc Areas merged selection drawing as a layer into the Misc Areas Drawing window.   

 

 

The Misc Areas merged selection drawing, as before, has a single area object.  That single area object is now the result of merging the two selected areas, the big area and the smaller area in the lower right that was overlapped by the big area.

 

 

As before, the Misc Areas merged selection drawing's table has a single record for a single area object.  The new area geometry is the merger of the two former selected areas.   The other areas, which were not selected, did not participate in the transform and their geometry has not been merged into the new object.

Merging using a Field (Dissolve)

A classic GIS operation is to merge areas that all have a particular field value in common into a single area object.  

 

Vector drawings that show states as areas may sometimes show the same state as made up of very many area objects, for example, the state of Maine in the United States might consist of hundreds of area objects, one for each island (the convoluted Atlantic coastline of Maine has many near offshore islands).   Such a representation can be inconvenient when we would prefer the entire state to be represented by a single, branched area object, so that selecting any part of Maine selects all of it, including all islands.

 

We can see an example below, in a drawing that shows provinces in Mexico as areas.   

 

 

The Mexico drawing at above left has been zoomed in to the far Western border between Baja California and Baja California Sur.  Each separate object has been styled to use a different color.   The green region at the bottom of the view is all part of Baja California Sur.

 

The three areas in the upper part of the view are all in the province of Baja California, which is represented in the drawing by three area objects.  The large orange object is the main part of Baja California, while the two very small area objects, the red object and the beige objects, are parts of peninsulas which extend past the formal dividing line between Baja California and Baja California Sur and which are non-contiguous parts of Baja California.  

 

The drawing's table at above right shows the records.  A similar situation occurs with the province of Campeche, which is represented by three area objects, two of which are an island and a small peninsula that also are not a contiguous part of the mainland area of Campeche.  We would like to merge areas in the Mexico drawing so all areas with the same Name field value are merged into one area.

 

With the focus on the drawing, in the Transform pane we choose the Geom field and then we choose the Merge template.

 

 

In the Merge template we choose the area (dissolve) operation.  We choose the Name field for the Group option.

 

We choose New Table and specify Mexico merged by name for the name of the new drawing and an analogous name for the new table.   Press Transform.

 

A new Mexico merged by name drawing appears in the Project pane.  We drag and drop the new Mexico merged by name drawing as a layer into the Mexico window.   

 

 

We style the Mexico merged by name drawing to use colors similar to those used in the Mexico drawing.  The green region at the bottom of the view is still Baja California Sur, while the upper, orange region is now all Baja California.     What appear to be three, orange, non-contiguous areas are all branches of the same, single area object, which appears in the drawing's table at above right with the name BAJA CALIFORNIA.

 

We Ctrl-click any part of the orange region to show that all of the apparently different areas are all part of the same, single area object.

 

 

All of the portions of the orange region are selected, being rendered in red selection color, as is the single record for Baja California in the table.

 

Merge : center

A merge into the center point of a minimum enclosing circle, either one center point for all objects together or into multiple center points for minimum enclosing circles of merged groups of objects when objects are grouped by a field,.  

 

Merge : center inner (area)

For areas only, a merge into the center point of a minimum enclosing circle as adjusted to fall within the original area, either one center point for all areas together or into multiple center points for minimum enclosing circles of merged groups of areas when areas are grouped by a field.   

 

Merge : center weight (area)

For areas only, a merge into the center of gravity point of the subject areas, as if they were cut out of cardboard, either one center point for all areas together or into multiple center of gravity points for merged groups of areas when areas are grouped by a field.  

 

Merge : circle

A merge into a minimum enclosing circular (in the coordinate system of the drawing) area,  either one circular area for all objects together or into multiple circular areas of merged groups of objects when objects are grouped by a field,.

 

Merge : convex hull

A merge into a convex hull area,  either one convex hull for all objects together or into multiple convex hulls for  merged groups of objects when objects are grouped by a field.

Merge : line

Take lines in the source geom field and merge them into a single line with branches for each of what originally were separate lines and place the result into the specified Result destination.   Areas and points are ignored.   

 

The Merge : line operation provides a Group option to specify a field that can be used for grouping the merge, to provide a classic GIS dissolve operation based on a field.   When a field is specified, all lines with the same value in that field will be merged into the same line.

 

We start with the sample drawing with three areas, two lines and two points.

 

 

Opening the drawing's table we can see records for the areas, lines and points.

 

With the focus on the drawing, in the Transform pane we choose the Geom field and then we choose the Merge template.

 

 

In the Merge template we choose the line operation.  We leave the Group option at the default (no field) setting, which will merge all areas in the drawing into a single area.  

 

We choose New Table and specify Merged Objects lines for the name of the new drawing and an analogous name for the new table.   Press Transform.

 

A new Merged Objects lines drawing appears in the Project pane.  We drag and drop the new Merged Objects lines drawing as a layer into the Objects Drawing window.   

 

 

The drawing has what appears to be two lines in it, but we know that these are all part of a single line object.   What appear to be two lines are really a single line object that has two branches.    Opening the new drawing's table we see it has one record.  

 

We Ctrl-click either of the lines in the drawing, to demonstrate they are all part of one line object.

 

Note that the upper branch looks slightly different from the original line.  The original line contained a curved segment.  Curved segments are replaced by straight line segments by the Merge : lines operation so the resulting branch has a straight line segment and is rendered differently.

Merging using a Field (Dissolve)

A classic GIS operation is to merge lines that all have a particular field value in common into a single line object.  

 

Vector drawings that show rivers or roads, for example, may often show a single road or river as many individual line objects laid end to end.  That can be inconvenient for selection or analysis, where we might prefer that a river or road be represented by a single line object.  

 

We can see an example below, in a drawing that shows rivers in Europe as lines, taken from the Natural Earth data set.

 

 

Ctrl-clicking on the Spree river that flows through Berlin selects the red lines shown above, and selects just one of the records with a name of Spree in the table.   This data set represents the Spree river with seven different line objects, one of which is composed of non-contiguous branches with gaps in between the branches.     We note from the table that other rivers are also represented by multiple, different, line objects.

 

We will merge all the line objects that have the same name into one object that has that name.

 

With the focus on the drawing, in the Transform pane we choose the Geom field and then we choose the Merge template.

 

 

In the Merge template we choose the line operation.  We choose the Name field for the Group option.

 

We choose New Table and specify Merged Rivers for the name of the new drawing and an analogous name for the new table.   Press Transform.

 

A new Merged Rivers drawing appears in the Project pane.  We drag and drop the new Merged Rivers drawing as a layer into the Rivers Map window.   

 

 

Now, when we Ctrl-click on the Spree river in either the drawing or the table only one record is selected.  All of the different line objects that formerly were placed in sequence have been merged into a single line object.    A quick look at the table shows that other rivers also have been merged so that now only a single line object represents each river.  Super!

 

Merge : points

Take points in the source geom field and merge them into a single multipoint with branches for each of what originally were separate points and place the result into the specified Result destination.   Areas and lines are ignored.   Multipoints are extremely confusing to lay people (and to many GIS practitioners as well), so the point operation should be used with great care.

 

The Merge : point operation provides a Group option to specify a field that can be used for grouping the merge, to provide a classic GIS dissolve operation based on a field.   When a field is specified, all points with the same value in that field will be merged into the same multipoint.

 

We start with the sample drawing with three areas, two lines and two points.

 

 

Opening the drawing's table we can see records for the areas, lines and points.

 

With the focus on the drawing, in the Transform pane we choose the Geom field and then we choose the Merge template.

 

 

In the Merge template we choose the points operation.  We leave the Group option at the default (no field) setting, which will merge all areas in the drawing into a single area.  

 

We choose New Table and specify Merged Objects points for the name of the new drawing and an analogous name for the new table.   Press Transform.

 

A new Merged Objects points drawing appears in the Project pane.  We drag and drop the new Merged Objects points drawing as a layer into the Objects Drawing window.   

 

 

The drawing has what appears to be two points in it, but we know that these are all part of a single multipoint object.   What appear to be two points are really a single multipoint object that has two branches.    Opening the new drawing's table we see it has one record.  

 

We Ctrl-click either of the points in the drawing, to demonstrate they are all part of one line object.

Merging using a Field (Dissolve)

Just as with doing a dissolve using Merge : area (dissolve) or Merge : line, using areas or lines, we can also choose a field name for the Group parameter to merge all points that have the same value in that field into the same multipoint.  

 

Merge : rectangle

Take objects in the source geometry field and construct the minimum vertically oriented rectangle that encloses each, aggregating fields from all of the objects into that new object, and then save into the Result destination.

 

The Merge : rectangle operation provides a Group option to specify a field that can be used for grouping the merge.    When a field is specified, all objects with the same value in that field will be merged into the same minimum enclosing rectangle.

 

We start with an example drawing with three areas, two lines and two points.

 

 

Opening the drawing's table we can see records for the various areas, lines and points.

 

 

With the focus on the drawing, in the Transform pane we choose the Geom field and then we choose the Merge template.

 

 

In the Merge template we choose the rectangle operation.  We leave the Group option at the default (no field) setting, which will merge all areas in the drawing into a single area.  

 

We choose New Table and specify Objects merged rectangle for the name of the new drawing and an analogous name for the new table.   Press Transform.

 

A new Objects merged rectangle drawing appears in the Project pane.  We drag and drop the new Objects merged rectangle drawing as a layer into the Objects Drawing window.    

 

 

The single object in the Objects merged rectangle drawing is a vertically oriented rectangle that is the minimum enclosing rectangle for all of the objects in the source drawing.

 

Opening the new drawing's table we see it has one object, an area.  The drawing contains a single rectangle.

 

 

We can use the Layers pane to set the opacity of the Objects merged rectangle drawing layer to 50%, so the lower layer shows through.  We have also colored the upper layer using Style.  This shows how the enclosing rectangle is the smallest that will enclose all the objects in the lower layer.

 

Note that the minimum enclosing rectangle appears to go through the middle of the symbol used to show the upper point.  The actual point is the dimensionless location at the very center of the round symbol used to represent the point.

Merging using a Field (Dissolve)

Just as with doing a dissolve using Merge : area (dissolve) or Merge : line, using areas or lines, we can also choose a field name for the Group parameter to merge all objects that have the same value in that field into the same minimum enclosing rectangle.

 

 

We start with a version of the example drawing called Object Colors that has a Color field added which gives the color to use for each object, as seen below in the drawing's table.  The drawing has been styled to color each object based on the value for that object in the Color field.

 

 

We will merge objects into minimum enclosing rectangles using the Color field to Group the merge operation.

 

With the focus on the drawing, in the Transform pane we choose the Geom field and then we choose the Merge template.

 

 

In the Merge template we choose the rectangle operation.  We choose the Color field for the Group option.

 

We choose New Table and specify Merged colors for the name of the new drawing and an analogous name for the new table.   Press Transform.

 

A new Merged colors drawing appears in the Project pane.  We drag and drop the new Merged colors drawing as a layer into the Object Colors window.   

 

 

In the illustration above, we have already styled the Merged colors drawing to use the value of the Color field of each object for the fill color.   We see that three rectangles have been created, with the objects from the original drawing that had orange as their Color value being merged into a single enclosing rectangle, those that had blue as their Color value being merged into a single enclosing rectangle, and those that had green as their Color value being merged into a single enclosing rectangle.

 

 

Opening the table for the Merged colors drawing we see how each of the minimum enclosing rectangles has inherited an aggregate value of the Color field from the objects that were merged into that rectangle using the Group criterion.

 

Merge : rectangle with rotation

A merge into an enclosing rectangular area freely rotated to whatever bearing alignment allows the smallest enclosing rectangle, either one rectangle for all objects together or into multiple rectangles of merged groups of objects when objects are grouped by a field.

 

See Also

Transform Pane

 

Transform Reference

 

Transform - Expression

 

Transform - Geometry

 

Example: Flooded Roads - We consider a hypothetical case of a 10 meter rise in sea level in the San Francisco Bay area, and we find what highways and major roads would be flooded by such a rise.   The example uses both raster and vector data sets, combines a number of techniques and uses the Contour, Buffer, Merge, and Clip transform templates.