Combine Geometries
The combine_geometries MCP tool intersects, subtracts, merges, or calculates an envelope around GeoJSON geometries.
Use this tool to calculate shared areas, remove one area from another, merge areas, or create a bounding envelope around up to 100 geometries.
Tool name
combine_geometries
Request URL
https://api.geoapify.com/v1/mcp?apiKey=YOUR_API_KEY
Input parameters
| Name | Type | Required | Description |
|---|---|---|---|
operation |
string | Yes | Combination operation: intersection, difference, union, or envelope. |
geometries |
array of GeoJSON geometries | Yes | Ordered input geometries. Provide between 1 and 100 values. |
intersection, difference, and union require at least two Polygon or MultiPolygon geometries. difference subtracts every later geometry from the first. envelope accepts one or more supported geometry types.
Operations
| Operation | Input | Output |
|---|---|---|
intersection |
2–100 polygons | Shared GeoJSON area or an empty result |
difference |
2–100 ordered polygons | Remaining GeoJSON area or an empty result |
union |
2–100 polygons | Merged GeoJSON geometry |
envelope |
1–100 geometries | Rectangular GeoJSON Polygon Feature |
Coordinates use WGS84 [longitude, latitude, optional elevation] order. Supported types are Point, LineString, Polygon, MultiPoint, MultiLineString, and MultiPolygon. Polygon rings must contain at least four positions and must be closed. The input schema does not allow additional properties.
Example request
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "combine_geometries",
"arguments": {
"operation": "intersection",
"geometries": [
{
"type": "Polygon",
"coordinates": [[[13.38, 52.5], [13.42, 52.5], [13.42, 52.54], [13.38, 52.54], [13.38, 52.5]]]
},
{
"type": "Polygon",
"coordinates": [[[13.4, 52.51], [13.44, 52.51], [13.44, 52.55], [13.4, 52.55], [13.4, 52.51]]]
}
]
}
}
}
Response
The tool returns structuredContent.type as geojson and the resulting GeoJSON value in structuredContent.data. An operation with no result returns type: "empty" and data: null.
Example response
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [{ "type": "text", "text": "{\"type\":\"geojson\",\"data\":{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[13.4,52.51],[13.42,52.51],[13.42,52.54],[13.4,52.54],[13.4,52.51]]]}}}" }],
"structuredContent": {
"type": "geojson",
"data": {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [[[13.4, 52.51], [13.42, 52.51], [13.42, 52.54], [13.4, 52.54], [13.4, 52.51]]]
}
}
},
"isError": false
}
}
Related tools
- Evaluate Spatial Relation - test how geometries relate without modifying them.
- Transform Geometry - buffer, simplify, or transform a geometry.
Related API
For direct HTTP API integration, see Geometry Operations API.
intersection
Use intersection with the combine_geometries tool to return the area shared by all input polygons.
Input
| Field | Type | Required | Description |
|---|---|---|---|
operation |
string | Yes | Must be intersection. |
geometries |
array | Yes | Between 2 and 100 Polygon or MultiPolygon geometries. |
Coordinates use WGS84 [longitude, latitude, optional elevation] order. Polygon rings must be closed.
Arguments example
{
"operation": "intersection",
"geometries": [
{ "type": "Polygon", "coordinates": [[[13.38, 52.5], [13.42, 52.5], [13.42, 52.54], [13.38, 52.54], [13.38, 52.5]]] },
{ "type": "Polygon", "coordinates": [[[13.4, 52.51], [13.44, 52.51], [13.44, 52.55], [13.4, 52.55], [13.4, 52.51]]] }
]
}
Output
type: "geojson"with the shared Polygon or MultiPolygon Feature indata.type: "empty"withdata: nullwhen the inputs have no shared area.
difference
Use difference with the combine_geometries tool to subtract every later polygon from the first polygon. Input order changes the result.
Input
| Field | Type | Required | Description |
|---|---|---|---|
operation |
string | Yes | Must be difference. |
geometries |
array | Yes | Between 2 and 100 ordered Polygon or MultiPolygon geometries. |
Coordinates use WGS84 [longitude, latitude, optional elevation] order. Polygon rings must be closed.
Arguments example
{
"operation": "difference",
"geometries": [
{ "type": "Polygon", "coordinates": [[[13.38, 52.5], [13.44, 52.5], [13.44, 52.55], [13.38, 52.55], [13.38, 52.5]]] },
{ "type": "Polygon", "coordinates": [[[13.4, 52.51], [13.46, 52.51], [13.46, 52.56], [13.4, 52.56], [13.4, 52.51]]] }
]
}
Output
type: "geojson"with the remaining Polygon or MultiPolygon Feature indata.type: "empty"withdata: nullwhen the subtraction removes the entire first geometry.
union
Use union with the combine_geometries tool to merge two or more polygons into one Polygon or MultiPolygon result.
Input
| Field | Type | Required | Description |
|---|---|---|---|
operation |
string | Yes | Must be union. |
geometries |
array | Yes | Between 2 and 100 Polygon or MultiPolygon geometries. |
Coordinates use WGS84 [longitude, latitude, optional elevation] order. Polygon rings must be closed.
Arguments example
{
"operation": "union",
"geometries": [
{ "type": "Polygon", "coordinates": [[[13.38, 52.5], [13.42, 52.5], [13.42, 52.54], [13.38, 52.54], [13.38, 52.5]]] },
{ "type": "Polygon", "coordinates": [[[13.4, 52.51], [13.44, 52.51], [13.44, 52.55], [13.4, 52.55], [13.4, 52.51]]] }
]
}
Output
Returns type: "geojson" with the merged Polygon or MultiPolygon Feature in data.
envelope
Use envelope with the combine_geometries tool to create the smallest axis-aligned rectangular polygon containing all input geometries.
Input
| Field | Type | Required | Description |
|---|---|---|---|
operation |
string | Yes | Must be envelope. |
geometries |
array | Yes | Between 1 and 100 supported GeoJSON geometries. Mixed geometry types are allowed. |
Supported types are Point, LineString, Polygon, MultiPoint, MultiLineString, and MultiPolygon. Coordinates use WGS84 [longitude, latitude, optional elevation] order.
Arguments example
{
"operation": "envelope",
"geometries": [
{ "type": "Point", "coordinates": [13.405, 52.52] },
{ "type": "LineString", "coordinates": [[13.38, 52.5], [13.44, 52.54]] }
]
}
Output
Returns type: "geojson" with a rectangular Polygon Feature in data.