Skip to main content

Union

In Geographic Information Systems (GIS), the union tool is used to combine multiple spatial datasets into a single dataset. This tool is commonly used to merge overlapping or adjacent geometries while preserving all attributes from the input datasets.

Union Illustration

How Union is Applied

Union combines input spatial features, retaining all original geometries and attributes. It creates a new dataset that includes the extent of all input features and resolves overlaps or intersections by creating shared boundaries. This is particularly useful for analyzing relationships between datasets or creating comprehensive coverage from multiple layers.

Again, GeoFlip supports union transformations for several popular GIS formats, including GeoJSON, Shapefile (SHP), DXF, and GeoPackage (GPKG). The following section provides details on how to use this transformation and offers example code.

Using the Union Transformation in GeoFlip

The GeoFlip API allows users to add a transformation parameter to the request payload. For union transformations, users can specify the input datasets to be combined.

Sample Parameters

{
"transformations": [
{
"type": "union"
}
]
}

Sample Payload with GeoJSON as Input

{
"input_geojson": {
"type": "FeatureCollection",
"name": "pre_union",
"crs": {
"type": "name",
"properties": {
"name": "urn:ogc:def:crs:OGC:1.3:CRS84"
}
},
"features": [
{
"type": "Feature",
"properties": {
"id": "0"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[115.004534885919085, -33.863087861319492],
[115.006017244900079, -33.867728067661496],
[114.998810450363862, -33.871312839562293],
[114.994940468525897, -33.868903766064086],
[114.99334108357283, -33.866214919277361],
[114.995566919002698, -33.858578746454484],
[114.998706191475478, -33.859964918715185],
[115.00437318983542, -33.86126955143115],
[115.004534885919085, -33.863087861319492]
]
]
}
},
{
"type": "Feature",
"properties": {
"id": "2"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[115.01266877068457, -33.854977460862578],
[115.01207919703468, -33.861225763369056],
[114.999496866967434, -33.862209169936378],
[114.99254355779324, -33.857317658141888],
[114.995278234554917, -33.850125479445929],
[115.01266877068457, -33.854977460862578]
]
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[114.99659451330058, -33.865003717859366],
[114.99334108357283, -33.86621491927736],
[114.9949404685259, -33.868903766064086],
[114.99881045036386, -33.87131283956229],
[115.00601724490008, -33.867728067661496],
[115.00420872774009, -33.86451480335258],
[114.99659451330058, -33.865003717859366]
]
]
}
}
]
},
"output_format": "geojson",
"transformations": [
{
"type": "union"
}
]
}

Parameters

  • type: Specifies the type of transformation. For union operation, "union" is applied to combine all input geometries and attributes into a single dataset.

Error Handling

Invalid transformation type
{
"code": 422,
"errors": {
"json": {
"transformations": {
"0": {
"type": ["Must be one of: buffer, clip, erase, dissolve, union."]
}
}
}
},
"status": "Unprocessable Entity"
}