Evaluate Spatial Relation
The evaluate_spatial_relation MCP tool evaluates containment, intersection, validity, and other spatial predicates for GeoJSON geometries.
Use this tool when an agent needs a boolean answer about one geometry or the relationship between two geometries.
Tool name
evaluate_spatial_relation
Request URL
https://api.geoapify.com/v1/mcp?apiKey=YOUR_API_KEY
Input parameters
| Name | Type | Required | Description |
|---|---|---|---|
operation |
string | Yes | Predicate: contains, crosses, disjoint, intersects, within, valid, or point_on_line. |
geometry |
GeoJSON geometry | Yes | Subject geometry. Operand order matters for contains and within; this must be a Point for point_on_line. |
other_geometry |
GeoJSON geometry | Conditionally | Comparison geometry. Required for every operation except valid; must be a LineString for point_on_line. |
Coordinates use WGS84 [longitude, latitude, optional elevation] order. Supported types are Point, LineString, Polygon, MultiPoint, MultiLineString, and MultiPolygon. The valid operation accepts only operation and geometry. The input schema does not allow additional properties.
Operations
| Operation | Input | Output |
|---|---|---|
contains |
Container and contained geometries | Boolean |
crosses |
Two geometries | Boolean |
disjoint |
Two geometries | Boolean |
intersects |
Two geometries | Boolean |
within |
Inner and container geometries | Boolean |
valid |
One geometry | Boolean |
point_on_line |
Point and LineString | Boolean |
Example request
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "evaluate_spatial_relation",
"arguments": {
"operation": "contains",
"geometry": {
"type": "Polygon",
"coordinates": [[[13.38, 52.5], [13.43, 52.5], [13.43, 52.55], [13.38, 52.55], [13.38, 52.5]]]
},
"other_geometry": {
"type": "Point",
"coordinates": [13.405, 52.52]
}
}
}
}
Response
The tool returns structuredContent.type as boolean and the predicate result in structuredContent.data.
Example response
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"content": [{ "type": "text", "text": "{\"type\":\"boolean\",\"data\":true}" }],
"structuredContent": {
"type": "boolean",
"data": true
},
"isError": false
}
}
Related tools
- Combine Geometries - intersect, subtract, merge, or envelope geometries.
- Measure Geometry - calculate numeric measurements or locate points on geometries.
Related API
For direct HTTP API integration, see Geometry Operations API.
contains
Use contains with evaluate_spatial_relation to test whether geometry completely contains other_geometry. Operand order is significant.
Input
| Field | Type | Required | Description |
|---|---|---|---|
operation |
string | Yes | Must be contains. |
geometry |
GeoJSON geometry | Yes | Container geometry. |
other_geometry |
GeoJSON geometry | Yes | Geometry that must be contained. |
Arguments example
{
"operation": "contains",
"geometry": { "type": "Polygon", "coordinates": [[[13.38, 52.5], [13.43, 52.5], [13.43, 52.55], [13.38, 52.55], [13.38, 52.5]]] },
"other_geometry": { "type": "Point", "coordinates": [13.405, 52.52] }
}
Output
Returns { "type": "boolean", "data": true } when containment is satisfied; otherwise data is false.
crosses
Use crosses with evaluate_spatial_relation to test whether two geometries cross one another.
Input
| Field | Type | Required | Description |
|---|---|---|---|
operation |
string | Yes | Must be crosses. |
geometry |
GeoJSON geometry | Yes | First geometry. |
other_geometry |
GeoJSON geometry | Yes | Second geometry. |
Arguments example
{
"operation": "crosses",
"geometry": { "type": "LineString", "coordinates": [[13.38, 52.5], [13.44, 52.54]] },
"other_geometry": { "type": "LineString", "coordinates": [[13.38, 52.54], [13.44, 52.5]] }
}
Output
Returns { "type": "boolean", "data": true } when the geometries cross; otherwise data is false.
disjoint
Use disjoint with evaluate_spatial_relation to test whether two geometries have no point in common.
Input
| Field | Type | Required | Description |
|---|---|---|---|
operation |
string | Yes | Must be disjoint. |
geometry |
GeoJSON geometry | Yes | First geometry. |
other_geometry |
GeoJSON geometry | Yes | Second geometry. |
Arguments example
{
"operation": "disjoint",
"geometry": { "type": "Point", "coordinates": [13.405, 52.52] },
"other_geometry": { "type": "Point", "coordinates": [2.3522, 48.8566] }
}
Output
Returns { "type": "boolean", "data": true } when the geometries are disjoint; otherwise data is false.
intersects
Use intersects with evaluate_spatial_relation to test whether two geometries share at least one point.
Input
| Field | Type | Required | Description |
|---|---|---|---|
operation |
string | Yes | Must be intersects. |
geometry |
GeoJSON geometry | Yes | First geometry. |
other_geometry |
GeoJSON geometry | Yes | Second geometry. |
Arguments example
{
"operation": "intersects",
"geometry": { "type": "Polygon", "coordinates": [[[13.38, 52.5], [13.42, 52.5], [13.42, 52.54], [13.38, 52.54], [13.38, 52.5]]] },
"other_geometry": { "type": "LineString", "coordinates": [[13.37, 52.52], [13.43, 52.52]] }
}
Output
Returns { "type": "boolean", "data": true } when the geometries intersect; otherwise data is false.
within
Use within with evaluate_spatial_relation to test whether geometry is completely within other_geometry. Operand order is significant.
Input
| Field | Type | Required | Description |
|---|---|---|---|
operation |
string | Yes | Must be within. |
geometry |
GeoJSON geometry | Yes | Geometry that must be inside the comparison geometry. |
other_geometry |
GeoJSON geometry | Yes | Container geometry. |
Arguments example
{
"operation": "within",
"geometry": { "type": "Point", "coordinates": [13.405, 52.52] },
"other_geometry": { "type": "Polygon", "coordinates": [[[13.38, 52.5], [13.43, 52.5], [13.43, 52.55], [13.38, 52.55], [13.38, 52.5]]] }
}
Output
Returns { "type": "boolean", "data": true } when geometry is within other_geometry; otherwise data is false.
valid
Use valid with evaluate_spatial_relation to check whether one GeoJSON geometry is valid.
Input
| Field | Type | Required | Description |
|---|---|---|---|
operation |
string | Yes | Must be valid. |
geometry |
GeoJSON geometry | Yes | Geometry to validate. |
Do not provide other_geometry. Coordinates use WGS84 [longitude, latitude, optional elevation] order, and polygon rings must be closed.
Arguments example
{
"operation": "valid",
"geometry": { "type": "Polygon", "coordinates": [[[13.38, 52.5], [13.43, 52.5], [13.43, 52.55], [13.38, 52.55], [13.38, 52.5]]] }
}
Output
Returns { "type": "boolean", "data": true } for a valid geometry; otherwise data is false.
point_on_line
Use point_on_line with evaluate_spatial_relation to test whether a Point lies on a LineString.
Input
| Field | Type | Required | Description |
|---|---|---|---|
operation |
string | Yes | Must be point_on_line. |
geometry |
Point |
Yes | Point to test. |
other_geometry |
LineString |
Yes | Line on which to test the point. |
Coordinates use WGS84 [longitude, latitude, optional elevation] order.
Arguments example
{
"operation": "point_on_line",
"geometry": { "type": "Point", "coordinates": [13.41, 52.52] },
"other_geometry": { "type": "LineString", "coordinates": [[13.38, 52.5], [13.44, 52.54]] }
}
Output
Returns { "type": "boolean", "data": true } when the Point lies on the LineString; otherwise data is false.