Erase
In Geographic Information Systems (GIS), the erase tool is used to remove specific areas from a spatial dataset based on a defined boundary. This tool is particularly useful when excluding certain regions or features from a dataset, allowing users to refine the scope of their analysis.
How Erase Boundaries are Applied
The erase operation requires an input dataset and an erase boundary (often another spatial dataset) that defines the area to be removed. The output retains only the portions of features outside the erase boundary, discarding data within it. Users can specify the erase boundary using administrative areas, custom-drawn polygons, or other relevant features.
GeoFlip supports erase 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 Erase Transformation in GeoFlip
The GeoFlip API allows users to add a transformation parameter to the request payload. For erase transformations, users can define the erase area and specify other settings.
Sample Parameters
{"transformations": [
{
"type": "erase",
"erasing_geojson": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
[115.00055818149542, -33.85763000305442],
[115.000118796604, -33.85852202104468],
[115.00065590871407, -33.858785587826944],
[115.00153481085249, -33.85931270516249],
[115.0010465568896, -33.8599005810478],
[115.00092457527643, -33.86131961672926],
[114.99987458522537, -33.864421117335155],
[115.0001190304153, -33.86533320786453],
[115.00155931232695, -33.865475099042236],
[115.0029996231874, -33.865535890760185],
[115.00256033834717, -33.8662857833484],
[115.00036371583423, -33.86669097205334],
[115.00070576299566, -33.8679270669914],
[115.00671017414857, -33.86979206951076],
[115.0072228016532, -33.86474544712347],
[115.01508336160595, -33.867157522772196],
[115.0137652229862, -33.86545487723542],
[115.01381377777739, -33.85878578977273],
[115.00055818149542, -33.85763000305442],
]
],
"type": "Polygon",
},
}
],
},
}
]
}
Sample Payload with GeoJSON as Input
{
"input_geojson": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[114.99613129776213, -33.859519225850065],
[114.99949686696743, -33.86220916993638],
[115.00559680322726, -33.86004343997021],
[115.0048817441612, -33.85595593539954],
[114.99756134180785, -33.85448784508991],
[114.99613129776213, -33.859519225850065]
]
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[115.01207507962403, -33.85738857042802],
[115.00774236899753, -33.86220921304859],
[115.01060259361918, -33.86678510823485],
[115.01518895809949, -33.86615662604939],
[115.02061525766646, -33.862977734307634],
[115.02090921536842, -33.85927494028098],
[115.01762758433455, -33.85588657488439],
[115.01207507962403, -33.85738857042802]
]
]
}
},
{
"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",
"output_crs": "EPSG:4326",
"transformations": [
{
"type": "erase",
"erasing_geojson": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[115.00055818149542, -33.85763000305442],
[115.000118796604, -33.85852202104468],
[115.00065590871407, -33.858785587826944],
[115.00153481085249, -33.85931270516249],
[115.0010465568896, -33.8599005810478],
[115.00092457527643, -33.86131961672926],
[114.99987458522537, -33.864421117335155],
[115.0001190304153, -33.86533320786453],
[115.00155931232695, -33.865475099042236],
[115.0029996231874, -33.865535890760185],
[115.00256033834717, -33.8662857833484],
[115.00036371583423, -33.86669097205334],
[115.00070576299566, -33.8679270669914],
[115.00671017414857, -33.86979206951076],
[115.0072228016532, -33.86474544712347],
[115.01508336160595, -33.867157522772196],
[115.0137652229862, -33.86545487723542],
[115.01381377777739, -33.85878578977273],
[115.00055818149542, -33.85763000305442]
]
]
}
}
]
}
}
],
"headers": {
"apiKey": "api_key"
}
}
Parameters
type
: Specifies the type of transformation. For erase operations, "erase" is used, which removes data within a defined boundary.erasing_geojson
: Defines the geographic area that will act as the boundary for the erase operation. It contains a GeoJSON-formatted structure to specify the erase boundary.type
(insideerasing_geojson
): Specifies the format type of the erase boundary. "FeatureCollection" is a standard GeoJSON type representing a collection of spatial features.features
: An array that contains individual spatial features. Multiple features can be included if the erase boundary is composed of more than one area.type
(insidefeatures
): Specifies the type of the feature, which is "Feature" in this case. Each feature has properties and geometry.properties
: A standard structure of GeoJSON. Typically used to store metadata or attributes associated with the feature.geometry
: Defines the actual geometry of the erase boundary.coordinates
: Contains the list of latitude and longitude coordinate pairs that define the vertices of the polygon. The coordinates must form a closed loop, meaning the first and last coordinate pairs should be identical to enclose the area fully.type
(insidegeometry
): Specifies the type of geometry used. "Polygon" indicates that the erase area is defined as a polygon.
Error Handling
Invalid transformation type
{
"code": 422,
"errors": {
"json": {
"transformations": {
"0": {
"type": ["Must be one of: buffer, clip, erase, dissolve, union."]
}
}
}
},
"status": "Unprocessable Entity"
}
Invalid erasing boundary
{
"code": 422,
"errors": {
"json": {
"transformations": {
"0": { "_schema": ["'erasing_geojson' must be provided for 'erase' transformations."] }
}
}
},
"status": "Unprocessable Entity"
}