Skip to content
TerraLabTerraLabDocs
Markdown

Buffer, clip, join, count or filter features

One GIS operation on a set of features: buffer, union, dissolve, intersection, difference, clip or simplify, returned as a file.

MCP toolprocess_geometry on https://mcp.terra-lab.ai/mcp
GroupMap data

Use it

Connect the MCP server to your assistant and ask in plain words: the assistant picks process_geometry when the request fits and fills the arguments below. These are valid arguments:

{"operation":"buffer","geojson":{"type":"LineString","coordinates":[[6.12,45.9],[6.13,45.905]]},"radius_m":200}
{"operation":"clip","url":"https://mcp.terra-lab.ai/dl/geojson/TOKEN/buildings.geojson","area":{"place":"Annecy","radius_m":150}}
{"operation":"count_within","url":"https://mcp.terra-lab.ai/dl/geojson/TOKEN/pois.geojson","with_url":"https://mcp.terra-lab.ai/dl/geojson/TOKEN/divisions.geojson"}

Parameters

NameTypeRequiredDescription
operationstringYesThe operation to apply. One of "buffer", "union", "intersection", "difference", "clip", "simplify", "centroid", "area_length", "count_within", "nearest", "select_by_location", "spatial_join", "filter".
fileobjectNoA file uploaded in the conversation (GeoJSON, KML, KMZ, GPX, zipped Shapefile, CSV or WKT).
file.download_urlstringYes
file.file_idstringYes
file.file_namestringNo
file.mime_typestringNo
urlstringNoA public http(s) link to the features, or a TerraLab download link from an earlier answer.
geojsonobjectNoThe features as a GeoJSON FeatureCollection, Feature or geometry in WGS 84 (longitude, latitude).
with_fileobjectNoThe second layer, uploaded in the conversation: for intersection, difference, clip, count_within, nearest, select_by_location and spatial_join.
with_file.download_urlstringYes
with_file.file_idstringYes
with_file.file_namestringNo
with_file.mime_typestringNo
with_urlstringNoA link to the second layer, or a TerraLab download link.
with_geojsonobjectNoThe second layer as GeoJSON in WGS 84. Only its polygons count, except for nearest and select_by_location, which take any geometry.
areaobjectNoFor clip: the area to keep, as a bbox or a place with a radius (its bounding box is used). The place the user asks about, not the user's own location.
area.bboxarray of numberNo[west, south, east, north] in decimal degrees (WGS 84). Exactly 4 items.
area.placestring or objectNoA place name or address, or a point.
area.radius_mnumberNoRadius around the place in metres. From 1 to 100000.
radius_mnumberNoFor buffer: the distance in metres (convert km or miles first). From 0.1 to 100000.
dissolvebooleanNoFor buffer: merge all buffers into one feature, so overlaps count once in the total area.
tolerance_mnumberNoFor simplify: the largest allowed shift of the outline in metres. From 0.01 to 100000.
dissolve_fieldstringNoFor union: dissolve into one feature per value of this field instead of one feature.
wherearray of objectNoFor filter: the conditions on attributes. A missing field equals null. Text that writes a number plainly ("12", "12.5") compares as a number; other text compares without case, and never orders against a number.
matchstringNoFor filter: keep the features that meet all conditions (default) or any of them. One of "all", "any".
relationstringNoFor select_by_location: keep the input features that intersect the second layer (default), lie wholly within one of its polygons, or lie within distance_m of it. One of "intersects", "within", "within_distance".
distance_mnumberNoFor select_by_location with relation within_distance: the distance in metres. From 0.1 to 100000.
invertbooleanNoFor select_by_location: keep the features that do not match instead.
sum_fieldstringNoFor count_within: also sum this numeric field of the counted features per polygon, as sum_.
join_fieldsarray of stringNoFor spatial_join and nearest: the fields of the second layer to copy. By default spatial_join copies all of them and nearest copies name (as nearest_name).
formatsarray of stringNoDownload formats. All five by default.
titlestringNoName for the map and the output files.

Response

structuredContent holds the result, content the same result as text for a model, and isError is true when the tool refused the request or failed; then structuredContent.code, message and hint say what to change.

{
  "structuredContent": {
    "sources": [{ "name": "...", "licence": "...", "url": "..." }],
    "downloads": [{ "label": "...", "format": "...", "url": "...", "name": "..." }]
  },
  "content": [{ "type": "text", "text": "..." }],
  "isError": false
}

Every result lists its sources with their licence. File results come as downloads: each link builds its file when opened.

Errors

A missing key answers 401, an empty balance 402, too many calls 429. A call that fails or finds nothing is not counted. See Errors and rate limits.

Description for agents

The text the server gives an agent to decide when to call this tool:

Use this when the user wants one GIS operation on a set of features (an uploaded file, a link, inline GeoJSON, or a download link from another TerraLab answer), with the result as a file. On one layer: buffer by radius_m (dissolve merges the buffers), union (dissolve all features into one, or one per value of dissolve_field), simplify by tolerance_m, centroid of each feature, area_length (adds area_m2, perimeter_m and length_m, geodesic), filter by attribute (where). With a second layer: intersection, difference, clip (or clip to an area: place, place with radius_m, or bbox), count_within (how many input features fall in each polygon, points in polygons, with an optional sum), nearest (the nearest feature of the second layer and its geodesic distance), select_by_location (the features that intersect it, lie within it, or lie within distance_m of it), spatial_join (copy the attributes of the polygon each feature falls in). Overlays and point in polygon run in WGS 84 degrees; buffer, simplify, centroid and distances in a local equidistant projection. Up to 20,000 features and 100,000 vertices per layer (25,000 for buffer). Returns counts, the fields, a few sample rows, total area or length, a map and GeoJSON, KML, Shapefile zip, GeoPackage and CSV downloads. Not for one distance or the area of a shape drawn in the chat: that is measure. Not for reading or converting a file without changing it: that is open_gis_file. Not for styling layers, print layouts or chaining steps on the layers of a QGIS project the user has open: TerraLab AI Agent in QGIS does that. Never use the user's current location unless they type it. Download links build their file when opened; no file is saved. The user opens the file in QGIS or any GIS: this server cannot load it into the user's own QGIS or any app on their computer. Never pass these links to open_gis_file: list every format the user needs in formats, in this one call. TerraLab reads the file or link to answer and keeps no copy.

Call it over HTTP

The same tool is also callable over HTTP with an API key: POST https://mcp.terra-lab.ai/v1/tools/process_geometry with the arguments as the JSON body.

curl -X POST https://mcp.terra-lab.ai/v1/tools/process_geometry \
  -H "Authorization: Bearer $TERRALAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"operation":"buffer","geojson":{"type":"LineString","coordinates":[[6.12,45.9],[6.13,45.905]]},"radius_m":200}'
import os
import requests

response = requests.post(
    "https://mcp.terra-lab.ai/v1/tools/process_geometry",
    headers={"Authorization": f"Bearer {os.environ['TERRALAB_API_KEY']}"},
    json={
        "operation": "buffer",
        "geojson": {
            "type": "LineString",
            "coordinates": [[6.12, 45.9], [6.13, 45.905]],
        },
        "radius_m": 200,
    },
    timeout=120,
)
response.raise_for_status()
print(response.json()["structuredContent"])
const response = await fetch('https://mcp.terra-lab.ai/v1/tools/process_geometry', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.TERRALAB_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "operation": "buffer",
    "geojson": {
      "type": "LineString",
      "coordinates": [
        [
          6.12,
          45.9
        ],
        [
          6.13,
          45.905
        ]
      ]
    },
    "radius_m": 200
  }),
});
const data = await response.json();
console.log(data.structuredContent);

Was this page helpful?

Updated Nov 23, 2026