Geometry Operations API
Combine, measure, test and transform GeoJSON geometries with one POST request. Send polygons, lines or points and get back a new geometry, a number or a true/false answer.
The API supports 42 operations, from union, buffer and area to point-in-polygon checks, Voronoi diagrams and k-means clustering. Every operation costs 1 credit.
On this page
Operations
The API takes GeoJSON geometries in the request body and returns one of four result types: geojson, number, boolean or empty. The 42 operations are grouped into 10 categories:
| Category | Operations | Result |
|---|---|---|
| Polygon set operations | union, intersection, difference | GeoJSON |
| Point sets and clustering | voronoi, clustersDbscan, clustersKmeans, concave, convex, tin | GeoJSON |
| Spatial predicates | contains, crosses, disjoint, intersects, within, valid | true / false |
| Measurement | distance, length, area, pointToLineDistance, pointToPolygonDistance | Number |
| Line operations | pointOnLine, nearestPointOnLine, lineIntersect, along | GeoJSON or true / false |
| Transformations | buffer, simplify, transformRotate, transformScale, transformTranslate | GeoJSON |
| Geometry centers | center, centerMean, centerMedian, centerOfMass | GeoJSON |
| Bounding and envelope | bbox, envelope | GeoJSON |
| Grid and random generators | grid, randomPoint, randomLineString, randomPolygon | GeoJSON |
| Queries and advanced | pointsWithinPolygon, greatCircle, tesselate | GeoJSON |
Each operation has its own input fields, for example polygon for area, geometry1 and geometry2 for contains, or polygons for union. See Supported Operations for the fields, options and a request example of every operation.
Request example
All operations use the same endpoint. The operation field selects what to do, and the other fields carry the geometries:
POST https://api.geoapify.com/v1/geometry/operation?apiKey=YOUR_API_KEY
Content-Type: application/jsonFor example, a store near Alexanderplatz in Berlin delivers within a rectangular zone. To check whether a customer's address is inside the zone, send the zone and the customer's location to contains. Coordinates are [longitude, latitude]:
const deliveryZone = {
type: "Polygon",
coordinates: [[[13.388, 52.53], [13.438, 52.53], [13.438, 52.51], [13.388, 52.51], [13.388, 52.53]]]
};
const response = await fetch("https://api.geoapify.com/v1/geometry/operation?apiKey=YOUR_API_KEY", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
operation: "contains",
geometry1: deliveryZone,
geometry2: { type: "Point", coordinates: [13.405, 52.52] }
})
});
console.log(await response.json()); // {"type":"boolean","data":true}A customer at [13.4545, 52.5096], east of the zone, gets {"type":"boolean","data":false}. With the same zone in "operation": "area" and "polygon": deliveryZone, the API returns the size in square meters, about 7.5 km²:
{ "type": "number", "data": 7523512.272821501 }Operations that build a shape return a GeoJSON Feature. A buffer of 500 meters around the store, with "params": { "units": "meters", "steps": 4 }, returns a 16-point polygon (shortened):
{
"type": "geojson",
"data": {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [[[13.420590157978372, 52.52189976986668], [13.420027883158841, 52.52362057857764], ..., [13.420590157978372, 52.52189976986668]]]
}
}
}Responses from requests made on 14 October 2026. Errors use HTTP status codes: 400 for invalid input or geometry, 401 for a missing or invalid API key, and 429 when the rate limit is exceeded. Try any operation without code in the Geometry Operations Playground.
Use cases
The Geometry Operations API is useful wherever an application has GeoJSON and needs an answer about it on the server, without adding a geometry library:
- Service areas: check whether an address is inside a delivery or service zone with
containsorwithin, and find the gaps between service areas and a target region. - Combining zones: merge overlapping delivery zones or isochrones with
union, find their overlap withintersection, or cut one area out of another withdifference. - Cleaning GeoJSON: validate shapes with
validbefore processing, andsimplifylarge polygons and lines before you draw them on a map. - Measuring: get polygon areas in square meters, line lengths and distances between points or from a point to a line or polygon.
- Grouping points: cluster customers or assets with DBSCAN or k-means, or split an area between locations with a Voronoi diagram.
Geometry tools for AI agents
The Geoapify MCP Server gives AI assistants four geometry tools based on these operations: combine_geometries, evaluate_spatial_relation, measure_geometry and transform_geometry. An agent can, for example, measure an area it built from search results or test whether a point lies inside a polygon. The MCP tools cover a subset of the operations; for all 42, call the REST API.
Geometry by ID for isolines
Some Geoapify APIs, such as the Isoline API, return an ID with each geometry they build. To combine those geometries without sending their coordinates, use the Geometry API: a GET request with operation=union or operation=intersection and two or more geometry IDs. It costs the number of geometries minus one in credits, so a union of 3 isolines costs 2 credits.
Pricing
Each request to the Geometry Operations API costs 1 credit, whatever the operation and however complex the input geometries are. The Free plan includes 3,000 credits per day, which is 3,000 operations, and no credit card is needed. See pricing plans for higher volumes and the Geometry Operations pricing in the docs.
Guides
These guides solve common tasks with the Geometry Operations API, with ready-to-run requests.
Prepare GeoJSON
Check and clean shapes before you process or display them.
- Validate GeoJSONBeginner7 min
- Simplify a large polygon or lineBeginner7 min
- Find the bounding boxBeginner5 min
- Find the center of a polygonIntermediate10 min
Measure
Get areas and lengths in real units.
- Calculate the area of a polygonBeginner5 min
- Calculate the length of a lineBeginner5 min
Combine areas
Merge, intersect, subtract and expand shapes.
- Merge overlapping polygonsBeginner7 min
- Find the overlap between polygonsBeginner7 min
- Subtract one area from anotherBeginner7 min
- Create a buffer around a geometryBeginner7 min
Service areas
Check coverage for delivery and service zones.
- Check if a location is inside a service areaIntermediate10 min
- Find gaps between service areasIntermediate15 min
FAQ
What is a geometry API?
A geometry API runs spatial operations on shapes for you: it merges or intersects polygons, measures areas and distances, tests whether one shape contains another, and builds new shapes such as buffers. The Geoapify Geometry Operations API does this for GeoJSON with 42 operations behind one endpoint. See the documentation.
Which data format does the Geometry Operations API use?
GeoJSON. Requests contain GeoJSON geometries with [longitude, latitude] coordinates, and results are GeoJSON, a number, or true/false. Field names depend on the operation, for example polygon for area or polygons for union; check Supported Operations.
How do I check if a point is inside a polygon?
Send "operation": "contains" with the polygon as geometry1 and the point as geometry2. The response is {"type":"boolean","data":true} when the point is inside. To check many points at once, use pointsWithinPolygon. Step by step: check whether a location is inside a service area.
How much does the Geometry Operations API cost?
Each request costs 1 credit, whatever the operation. The Free plan includes 3,000 credits per day; see pricing.
Can I combine isolines with the Geometry Operations API?
Yes. Send the isoline polygons to union or intersection. If you only have the isoline IDs returned by the Isoline API, use the ID-based Geometry API instead.
Can AI assistants use geometry operations?
Yes. Geoapify MCP Server provides four geometry tools to combine, compare, measure and transform GeoJSON geometries. Tool calls are billed like the underlying API requests.
