# Class UnaryUnionOp

Unions a `Collection`

of Geometrys or a single Geometry (which may be a GeometryCollection) together.

##### Inherited Members

**Namespace**: NetTopologySuite.Operation.Union

**Assembly**: NetTopologySuite.dll

##### Syntax

`public class UnaryUnionOp`

**Remarks**

By using this special-purpose operation over a collection of geometries it is possible to take advantage of various optimizations to improve performance.

Heterogeneous GeometryCollections are fully supported.

The result obeys the following contract:

- Unioning a set of Polygons has the effect of merging the areas (i.e. the same effect as iteratively unioning all individual polygons together).
- Unioning a set of LineStrings has the effect of
**fully noding**and**dissolving**the input linework. In this context "fully noded" means that there will be an endpoint or node in the result for every endpoint or line segment crossing in the input. "Dissolved" means that any duplicate (e.g. coincident) line segments or portions of line segments will be reduced to a single line segment in the output. This is consistent with the semantics of the Union(Geometry) operation. If**merged**linework is required, the LineMerger class can be used. - Unioning a set of Points has the effect of merging all identical points (producing a set with no duplicates).

`UnaryUnion`

always operates on the individual components of MultiGeometries.
So it is possible to use it to "clean" invalid self-intersecting MultiPolygons
(although the polygon components must all still be individually valid.)

### Constructors

| Improve this Doc View Source#### UnaryUnionOp(Geometry)

Constructs a unary union operation for a Geometry (which may be a GeometryCollection).

##### Declaration

`public UnaryUnionOp(Geometry geom)`

##### Parameters

Type | Name | Description |
---|---|---|

Geometry | geom | A geometry to union |

#### UnaryUnionOp(IEnumerable<Geometry>)

Constructs a unary union operation for an enumeration of Geometrys, using the GeometryFactory of the input geometries.

##### Declaration

`public UnaryUnionOp(IEnumerable<Geometry> geoms)`

##### Parameters

Type | Name | Description |
---|---|---|

IEnumerable<Geometry> | geoms | An enumeration of geometries |

#### UnaryUnionOp(IEnumerable<Geometry>, GeometryFactory)

Constructs a unary union operation for an enumeration of Geometrys.

If no input geometries were provided but a GeometryFactory was provided,

##### Declaration

`public UnaryUnionOp(IEnumerable<Geometry> geoms, GeometryFactory geomFact)`

##### Parameters

Type | Name | Description |
---|---|---|

IEnumerable<Geometry> | geoms | An enumeration of geometries |

GeometryFactory | geomFact | The geometry factory to use if the enumeration is empty |

### Properties

| Improve this Doc View Source#### UnionStrategy

##### Declaration

`public UnionStrategy UnionStrategy { get; set; }`

##### Property Value

Type | Description |
---|---|

UnionStrategy |

##### Remarks

Named setter named setUnionFun[ction] in JTS

### Methods

| Improve this Doc View Source#### Union()

Gets the union of the input geometries.

The result of empty input is determined as follows:

##### Declaration

`public Geometry Union()`

##### Returns

Type | Description |
---|---|

Geometry | A Geometry containing the union,
or an empty atomic geometry, or an empty |

#### Union(Geometry)

Constructs a unary union operation for a Geometry (which may be a GeometryCollection).

##### Declaration

`public static Geometry Union(Geometry geom)`

##### Parameters

Type | Name | Description |
---|---|---|

Geometry | geom | A geometry to union |

##### Returns

Type | Description |
---|---|

Geometry | The union of the elements of the geometry or an empty GEOMETRYCOLLECTION |

#### Union(IEnumerable<Geometry>)

Computes the geometric union of a IEnumerable<T>

##### Declaration

`public static Geometry Union(IEnumerable<Geometry> geoms)`

##### Parameters

Type | Name | Description |
---|---|---|

IEnumerable<Geometry> | geoms | A collection of geometries |

##### Returns

Type | Description |
---|---|

Geometry | The union of the geometries,
or |

#### Union(IEnumerable<Geometry>, GeometryFactory)

Computes the geometric union of a IEnumerable<T>

If no input geometries were provided but a GeometryFactory was provided, an empty GeometryCollection is returned.

##### Declaration

`public static Geometry Union(IEnumerable<Geometry> geoms, GeometryFactory geomFact)`

##### Parameters

Type | Name | Description |
---|---|---|

IEnumerable<Geometry> | geoms | A collection of geometries |

GeometryFactory | geomFact | The geometry factory to use if the collection is empty |

##### Returns

Type | Description |
---|---|

Geometry | The union of the geometries or an empty GEOMETRYCOLLECTION |