Clip
In Geographic Information Systems (GIS), the clip tool is used to extract a portion of a spatial dataset based on a defined area. This tool is useful for isolating areas of interest within a larger dataset, allowing users to focus their analysis on a specific region.

How Clip Boundaries are Applied
Clipping requires an input dataset and a clip boundary (often another spatial dataset) that defines the area to be retained. The output contains only the portions of features within the boundary, discarding data outside it. Users can specify the clip boundary based on administrative areas, custom-drawn polygons, or other areas of interest.
GeoFlip supports clip 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 Clip Transformation in GeoFlip
The GeoFlip API allows users to add a transformation parameter to the request payload. For clip transformations, users can define the clip area and specify other settings.
Sample Parameters
{
"transformations": [
{
"type": "clip",
"clipping_geojson": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
[115.00121521372733, -33.856853220096795],
[115.00121521372733, -33.866565353453026],
[115.01315471132949, -33.866565353453026],
[115.01315471132949, -33.856853220096795],
[115.00121521372733, -33.856853220096795]
]
],
"type": "Polygon"
}
}
]
}
}
]
}
Sample Payload with GeoJSON as Input
{
"input_geojson": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"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": "Polygon"
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"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": "Polygon"
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"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]
]
],
"type": "Polygon"
}
}
]
},
"output_format": "geojson",
"transformations": [
{
"type": "clip",
"clipping_geojson": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
[115.00121521372733, -33.856853220096795],
[115.00121521372733, -33.866565353453026],
[115.01315471132949, -33.866565353453026],
[115.01315471132949, -33.856853220096795],
[115.00121521372733, -33.856853220096795]
]
],
"type": "Polygon"
}
}
],
"bbox": [
114.992443628595, -33.87205788335776, 115.02180720159141,
-33.8537424269262
]
}
}
]
}
Parameters
type
: Specifies the type of transformation. For clip operation, "clip" is being applied, which will use a defined boundary to extract or limit data within that area.clipping_geojson
: Defines the geographic area that will act as the boundary for the clip operation. It contains a GeoJSON-formatted structure to specify the clipping boundary.type
(insideclipping_geojson
): Specifies the format type of the clipping boundary. "FeatureCollection" is a standard GeoJSON type representing a collection of spatial features.features
: An array that contains individual spatial features. Multiple features could be included if clipping boundary is more than one.type
(insidefeatures
): Specifies the type of the feature, which is "Feature" in this case. Each feature has properties and geometry.properties
: Standard structure of GeoJSON. Normally could store metadata or attributes associated with the feature.geometry
: Defines the actual geometry of the clipping 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 clipping 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 clipping boundary
{
"code": 422,
"errors": {
"json": {
"transformations": {
"0": { "_schema": ["Invalid clipping_geojson format."] }
}
}
},
"status": "Unprocessable Entity"
}