Measure Geometry

The measure_geometry MCP tool measures areas, line lengths, and distances, calculates bounds, or locates points along and nearest to GeoJSON geometries.

Use this tool for numeric geometry calculations and point-location operations without calling separate geometry endpoints.

Tool name


measure_geometry


Request URL


https://api.geoapify.com/v1/mcp?apiKey=YOUR_API_KEY


Input parameters

Name Type Required Description
operation string Yes area, distance, length, bbox, point_to_line_distance, point_to_polygon_distance, nearest_point_on_line, or along.
geometry GeoJSON geometry Yes Primary geometry. Its required type depends on the operation.
other_geometry GeoJSON geometry Conditionally Second point, target line, or target polygon. Required by distance, point-to-geometry, and nearest-point operations.
distance number Conditionally Distance from the start of a LineString. Required only for along, in the selected units.
units string No Units for distance-based operations. Default: kilometers. See supported units below.
recompute boolean No For bbox, set to true to ignore a pre-existing bounding box and recalculate it from coordinates. Default: false.

Operation geometry requirements:

Operation Geometry inputs Result
area Polygon or MultiPolygon Number in square meters
distance Two Point geometries Number in selected units
length LineString or MultiLineString Number in selected units
bbox Any supported geometry GeoJSON bounding-box polygon
point_to_line_distance Point and LineString Number in selected units
point_to_polygon_distance Point and Polygon or MultiPolygon Number in selected units
nearest_point_on_line Point and LineString or MultiLineString GeoJSON point feature
along LineString plus distance GeoJSON point feature

Supported units are meters, metres, millimeters, millimetres, centimeters, centimetres, kilometers, kilometres, miles, nauticalmiles, inches, yards, feet, radians, and degrees.

Coordinates use WGS84 [longitude, latitude, optional elevation] order. Each operation accepts only its listed fields, and the input schema does not allow additional properties.

Example request

{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "measure_geometry",
    "arguments": {
      "operation": "length",
      "geometry": {
        "type": "LineString",
        "coordinates": [[13.38, 52.5], [13.44, 52.54]]
      },
      "units": "meters"
    }
  }
}

Response

Numeric operations return structuredContent.type as number; operations that locate a point or calculate bounds return geojson. The result is in structuredContent.data.

Example response

{
  "jsonrpc": "2.0",
  "id": 3,
  "result": {
    "content": [{ "type": "text", "text": "{\"type\":\"number\",\"data\":6021.921081493014}" }],
    "structuredContent": {
      "type": "number",
      "data": 6021.921081493014
    },
    "isError": false
  }
}

Related tools

Related API

For direct HTTP API integration, see Geometry Operations API.

area

Use area with measure_geometry to calculate polygon area.

Input

Field Type Required Description
operation string Yes Must be area.
geometry Polygon or MultiPolygon Yes Geometry to measure.

Arguments example

{
  "operation": "area",
  "geometry": { "type": "Polygon", "coordinates": [[[13.38, 52.5], [13.42, 52.5], [13.42, 52.54], [13.38, 52.54], [13.38, 52.5]]] }
}

Output

Returns type: "number"; data is the area in square meters.

distance

Use distance with measure_geometry to calculate the geodesic distance between two points.

Input

Field Type Required Description
operation string Yes Must be distance.
geometry Point Yes Starting point.
other_geometry Point Yes Destination point.
units string No Result units. Default: kilometers.

Arguments example

{
  "operation": "distance",
  "geometry": { "type": "Point", "coordinates": [13.405, 52.52] },
  "other_geometry": { "type": "Point", "coordinates": [13.376, 52.5096] },
  "units": "meters"
}

Output

Returns type: "number"; data is the distance in the selected units.

length

Use length with measure_geometry to calculate the total length of a line geometry.

Input

Field Type Required Description
operation string Yes Must be length.
geometry LineString or MultiLineString Yes Line geometry to measure.
units string No Result units. Default: kilometers.

Arguments example

{
  "operation": "length",
  "geometry": { "type": "LineString", "coordinates": [[13.38, 52.5], [13.41, 52.53], [13.44, 52.54]] },
  "units": "meters"
}

Output

Returns type: "number"; data is the total length in the selected units.

bbox

Use bbox with measure_geometry to calculate the rectangular bounds of a geometry.

Input

Field Type Required Description
operation string Yes Must be bbox.
geometry GeoJSON geometry Yes Any supported geometry type.
recompute boolean No Set to true to ignore a pre-existing bounding box. Default: false.

Arguments example

{
  "operation": "bbox",
  "geometry": { "type": "LineString", "coordinates": [[13.38, 52.5], [13.41, 52.53], [13.44, 52.54]] },
  "recompute": true
}

Output

Returns type: "geojson"; data is a rectangular Polygon Feature. Its properties.bbox is [west, south, east, north].

point_to_line_distance

Use point_to_line_distance with measure_geometry to calculate the shortest distance from a Point to a LineString.

Input

Field Type Required Description
operation string Yes Must be point_to_line_distance.
geometry Point Yes Point to measure from.
other_geometry LineString Yes Target line.
units string No Result units. Default: kilometers.

Arguments example

{
  "operation": "point_to_line_distance",
  "geometry": { "type": "Point", "coordinates": [13.405, 52.52] },
  "other_geometry": { "type": "LineString", "coordinates": [[13.38, 52.5], [13.44, 52.54]] },
  "units": "meters"
}

Output

Returns type: "number"; data is the shortest distance in the selected units.

point_to_polygon_distance

Use point_to_polygon_distance with measure_geometry to calculate the shortest distance from a Point to a polygon boundary.

Input

Field Type Required Description
operation string Yes Must be point_to_polygon_distance.
geometry Point Yes Point to measure from.
other_geometry Polygon or MultiPolygon Yes Target polygon boundary.
units string No Result units. Default: kilometers.

Arguments example

{
  "operation": "point_to_polygon_distance",
  "geometry": { "type": "Point", "coordinates": [13.405, 52.52] },
  "other_geometry": { "type": "Polygon", "coordinates": [[[13.38, 52.5], [13.42, 52.5], [13.42, 52.54], [13.38, 52.54], [13.38, 52.5]]] },
  "units": "meters"
}

Output

Returns type: "number"; data is the shortest distance to the boundary in the selected units.

nearest_point_on_line

Use nearest_point_on_line with measure_geometry to locate the closest point on a line.

Input

Field Type Required Description
operation string Yes Must be nearest_point_on_line.
geometry Point Yes Point from which to search.
other_geometry LineString or MultiLineString Yes Target line.
units string No Units used by distance metadata. Default: kilometers.

Arguments example

{
  "operation": "nearest_point_on_line",
  "geometry": { "type": "Point", "coordinates": [13.405, 52.52] },
  "other_geometry": { "type": "LineString", "coordinates": [[13.38, 52.5], [13.44, 52.54]] },
  "units": "meters"
}

Output

Returns type: "geojson"; data is the nearest Point Feature with line-location metadata in properties.

along

Use along with measure_geometry to locate a point at a specified distance from the start of a LineString.

Input

Field Type Required Description
operation string Yes Must be along.
geometry LineString Yes Line along which to measure.
distance number Yes Distance from the start in the selected units.
units string No Distance units. Default: kilometers.

Arguments example

{
  "operation": "along",
  "geometry": { "type": "LineString", "coordinates": [[13.38, 52.5], [13.41, 52.53], [13.44, 52.54]] },
  "distance": 1000,
  "units": "meters"
}

Output

Returns type: "geojson"; data is the Point Feature at the requested distance along the line.