mapsmith

v0.13.1
io.github.mapsmith-ai/mapsmith Checked 4 hours ago Published 4 days ago

Deterministic GIS geoprocessing with verifiable provenance on every output

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

describe_dataset

Inspect a dataset, vector or raster, before analysing it. Vector: CRS, geometry types, schema, extent, feature count. A MULTI-LAYER container (e.g. a GeoPackage holding several layers) is described per layer — name, feature count, geometry type, CRS — because operations refuse containers with no chosen layer: extract the layer you mean first (run_sql: SELECT * FROM ST_Read(path, layer='name') with an output_path). Raster (.tif): CRS, grid size, resolution, bands with dtype, nodata and masked statistics (nodata cells counted separately). Call this first on any dataset you have not inspecte…

ParameterTypeDescription
path *string

buffer_layer

Buffer all features by a distance in meters. Geographic-CRS inputs are reprojected to an estimated UTM zone for the metric operation and back; the decision is recorded in the provenance manifest. A `warnings` key in the result flags a suspicious-but-valid outcome with a hint — e.g. a negative distance that eroded every geometry away.

ParameterTypeDescription
distance_meters *number
input_path *string
output_path *string

clip_layer

Clip a layer to the area of a mask layer. CRS are aligned automatically. A `warnings` key in the result means the analysis ran but something is worth your attention (typically an empty result, or inputs whose extents do not overlap); each entry carries a hint. Inputs without a CRS are refused.

ParameterTypeDescription
input_path *string
mask_path *string
output_path *string

overlay_layers

Set-theoretic overlay of two layers: intersection (default), union, identity, symmetric_difference or difference. The overlay layer is reprojected to the input CRS when they differ; the decision is recorded in the provenance manifest. Overlay pieces of lower dimension than the inputs (shared edges, corner contacts) are dropped, and the manifest says so. Inputs without a CRS are refused; an empty result comes back with a `warnings` entry, never as a silent success.

ParameterTypeDescription
input_path *string
output_path *string
overlay_path *string
howstring

dissolve_layer

Merge features into one geometry per value of `by` (or one feature in all). aggfunc — first (default), last, sum, mean, median, min, max or count — is applied to the other columns and RECORDED in the manifest: a sum reported where a mean was meant is a plausible wrong number nobody can see. Features with a null `by` key are dropped by the grouping and the manifest counts them. The output feature count is verified against the number of distinct keys, so a wrong grouping fails loudly instead of shipping.

ParameterTypeDescription
input_path *string
output_path *string
aggfuncstring
by

nearest_join

Attach each feature's nearest neighbour from another layer, with the distance IN METERS in a named column. Geographic-CRS inputs are measured in an estimated UTM zone (decision recorded in the manifest) and returned in the input CRS — a nearest distance in degrees is the classic silent error of this operation, and it cannot happen here. max_distance_meters drops pairs farther than that; an emptied result comes back with a `warnings` entry, never silently.

ParameterTypeDescription
left_path *string
output_path *string
right_path *string
distance_columnstring
max_distance_meters

explode_layer

Split multi-part geometries into one feature per part (attributes copied). The output feature count is verified against the number of parts counted before the engine ran, so a lost part fails loudly instead of shipping. Inputs without a CRS are refused.

ParameterTypeDescription
input_path *string
output_path *string

measure_area

Area per feature in SQUARE METRES, written to a named column, with the total in the result. method='geodesic' (default) measures ground area on the ellipsoid the layer's CRS names: no map plane, so no projection distortion. method= 'planar' measures in the layer's own CRS and converts with its declared linear unit — a layer in US survey feet is not assumed to be in metres — and is refused on a geographic CRS, where an area would be in square degrees. Two things this tool does that a bare area call cannot: invalid geometry is repaired BEFORE measuring (the planar area of a self-intersecti…

ParameterTypeDescription
input_path *string
output_path *string
area_columnstring
methodstring

merge_layers

Append two or more layers into one (schema union, attributes aligned by name). Layers are reprojected to the FIRST layer's CRS when they differ; the decision is recorded in the provenance manifest. Columns present in only some inputs are null-filled in the others and the manifest names them — data that looks measured and is actually absent is a silent error. The output feature count is verified against the sum of the input counts. Inputs without a CRS are refused. This is an append, not a geometric union: use dissolve_layer to merge geometries afterwards.

ParameterTypeDescription
input_paths *array
output_path *string

simplify_layer

Simplify geometries (Douglas-Peucker, topology preserved) with the drift measured: the manifest records total area and length before and after. Geographic-CRS inputs are simplified in an estimated UTM zone (decision recorded) and returned in the input CRS — a tolerance in degrees is a different distance at every latitude. On projected CRS the tolerance is interpreted in the CRS units. The feature count is verified unchanged; vertex counts before/after are in the result. Inputs without a CRS are refused.

ParameterTypeDescription
input_path *string
output_path *string
tolerance_meters *number

centroid_layer

One point per feature: the geometric centroid, computed in a metric CRS. Geographic-CRS inputs are measured in an estimated UTM zone (decision recorded in the manifest) and returned in the input CRS — a planar centroid of degree coordinates lands in the wrong place, quietly. The output is verified: same feature count, Point geometry, input CRS. Note the manifest's caveat: the centroid of a concave or multi-part feature can fall outside it. Inputs without a CRS are refused.

ParameterTypeDescription
input_path *string
output_path *string

convert_format

Convert a vector dataset between formats; the target is chosen by the output extension (.parquet, .gpkg, .geojson). The output is re-read and verified: same feature count, same CRS. Two conversions are refused with the reason: shapefile (field names truncated to 10 characters, silently) and GeoJSON for non-WGS84 layers (RFC 7946 is WGS84 by definition — reproject first). Invalid geometry carried through is repaired deterministically and reported in a 'repairs' key.

ParameterTypeDescription
input_path *string
output_path *string

reproject_layer

Reproject a layer to a target CRS, e.g. 'EPSG:32632' or a WKT string. Inputs without a CRS are refused. Geometry passes through unchanged, so an invalid input yields an invalid output: mechanically broken geometry is repaired deterministically and reported in a `repairs` key — read it, the geometry type may have changed.

ParameterTypeDescription
input_path *string
output_path *string
target_crs *string

spatial_join

Join by spatial predicate (intersects/within/contains). engine='auto' routes to the fastest available engine for the inputs: SedonaDB (heavy joins, 10-180x) > DuckDB (GeoParquet fast path) > GeoPandas. A `warnings` key in the result flags an empty join or inputs whose extents do not overlap, each with a hint. Inputs without a CRS are refused.

ParameterTypeDescription
left_path *string
output_path *string
right_path *string
enginestring
predicatestring

run_sql

Run spatial SQL (DuckDB dialect, ST_* functions, read_parquet/ST_Read for files). Without output_path: returns up to 50 preview rows. With output_path (.parquet): materializes the full result as GeoParquet with a provenance manifest. input_paths declares every dataset read; when omitted, the engine derives them from the query. Under MAPSMITH_WORKSPACE only SELECT runs, and coordinate systems (ST_Transform, ST_SetCRS) and dataset paths (ST_Read, read_parquet) must be string literals, so they can be checked before anything opens them; ST_Read takes there the formats whose coordinate system MapS…

ParameterTypeDescription
query *string
input_paths
output_pathstring

zonal_statistics

Statistics of a raster within each vector zone (exact fractional pixel coverage). stats: subset of count/sum/mean/median/min/max/stdev/variance/majority/minority/ variety (default: count, mean, min, max). Zones are aligned to the raster CRS automatically; the decision is recorded in the provenance manifest. weights_path: a single-band raster of weights on the SAME grid as the values (same CRS, cells and registration; otherwise refused with how to align it), for weighted_mean/weighted_sum/weighted_stdev/weighted_variance/weighted_frac -- e.g. mean heat per zone weighted by population (default…

ParameterTypeDescription
output_path *string
raster_path *string
zones_path *string
stats
weights_path

hillshade

Shaded relief from a DEM: GeoTIFF in, GeoTIFF out (values scaled 0-32767). azimuth = sun direction in degrees (default 315, NW); altitude = sun angle above the horizon (default 30). DEMs without a CRS are rejected. Requires the [whitebox] extra.

ParameterTypeDescription
dem_path *string
output_path *string
altitudenumber
azimuthnumber
z_factornumber

slope

Slope gradient from a DEM: GeoTIFF in, GeoTIFF out. units: degrees (default), percent or radians. DEMs in a geographic CRS are refused — degree cells with meter elevations give plausible but wrong values everywhere; reproject to a projected CRS first. The CRS decision is recorded in the provenance manifest. Requires the [whitebox] extra.

ParameterTypeDescription
dem_path *string
output_path *string
unitsstring
z_factornumber

aspect

Aspect from a DEM: downslope azimuth in degrees, 0 = north. GeoTIFF in/out. FLAT CELLS ARE -1, not nodata — mask them before averaging aspect over an area, or the average is plausibly wrong. DEMs in a geographic CRS are refused (see slope): reproject to a projected CRS first. Requires the [whitebox] extra.

ParameterTypeDescription
dem_path *string
output_path *string
z_factornumber

flow_accumulation

D8 flow accumulation from a DEM (GeoTIFF in/out). Depressions are filled first. out_type: 'cells' (upslope cell count, includes the cell itself) or 'sca' (specific catchment area). log_transform=True for visualization-friendly values. Requires the [whitebox] extra.

ParameterTypeDescription
dem_path *string
output_path *string
log_transformboolean
out_typestring

watershed

Watershed of each pour point: DEM + points in, basin raster out (GeoTIFF). Basins get 1-based IDs following the pour-point feature order; cells not draining to any point stay nodata. Points are aligned to the DEM CRS automatically (decision recorded). Requires the [whitebox] extra.

ParameterTypeDescription
dem_path *string
output_path *string
pour_points_path *string

validate_plan

Statically validate a multi-step geoprocessing plan BEFORE running anything. Write the plan as steps in execution order; each step has a unique id, an operation name from list_operations, and its arguments. Use "$step_id" as an argument value to consume the output dataset of an earlier step. Checks: operations exist and are installed, arguments complete and well-typed, references resolve backwards (mis-ordered steps are rejected), input files exist, outputs don't collide, and CRS flow is simulated end-to-end from the real input files. Returns machine-actionable errors/warnings/notes plus the…

ParameterTypeDescription
plan *

brief_plan

Render a project brief from a plan that has ALREADY passed validation. Every statement carries its source: operation declaration, argument rule, validation finding, engine availability or install requirement. Invalid plans return only the validation report and no project text. Installation commands are printed for the person to run; MapSmith never installs an engine.

ParameterTypeDescription
plan *

execute_plan

Validate, then execute a geoprocessing plan step by step. The plan is re-validated first (an invalid plan runs nothing). Steps run in order; "$step_id" references resolve to the outputs of earlier steps. Every step writes its own provenance manifest, and a plan-level manifest (<last output>.plan.json, with the plan sha256 and per-step outcomes) ties them together. Execution stops at the first failing step; outputs already produced stay on disk with their manifests. Same plan format as validate_plan — validate first, then execute. A `step_warnings` key in the response means the plan ran but…

ParameterTypeDescription
plan *
repair

get_provenance

Return the manifest of the ONE operation that wrote this dataset. Its inputs with their digests, the exact parameters, the CRS decisions with reasons, engine and version, and every deterministic check with its result. One step, in full. For the whole chain that led here — the operations behind the inputs, and the ones behind those — the catalogue operation `get_lineage` walks it and returns each step summarised instead of one step complete; run it through `run_operation`. It is not a tool of its own on purpose: two exposed tools answering the same question about the same file is the overl…

ParameterTypeDescription
output_path *string

preview_map

Show datasets on the interactive in-chat map panel (MCP Apps). Pass the paths of one or more MapSmith outputs or source datasets (vector or GeoTIFF). Layers are previewed in EPSG:4326 with simplified geometry and capped feature counts sized to fit client limits; each layer card shows its provenance summary and verification status. Read-only: the datasets of record stay on disk. On clients without MCP Apps support the same payload is returned as structured data.

ParameterTypeDescription
paths *array
max_featuresinteger

list_operations

Find the operation you need. **Say what you have and what you want** — it matters more than the words you search with. Ranking alone does not scale, and this is measured rather than assumed on independently written requests. Declaring what you already know makes ranking less important: when few enough operations survive, the whole set is handed over rather than a ranked shortlist. Delivery is not an accuracy figure: it depends on the surviving set staying small enough to return whole. So fill these in whenever you know them, and you usually do: - **input_kind** — what you are holding: '…

ParameterTypeDescription
category
dataset_inputs
detailboolean
enginestring
geometry
input_kind
limitinteger
produces
projected
querystring

run_operation

Run ANY catalog operation by name, including the ones with no tool of their own — which is most of them, and increasingly so. The tools above are the handful an agent reaches for constantly. The catalog holds every operation MapSmith can perform, and it grows faster than the tool list on purpose: tool-selection accuracy degrades past a few dozen exposed tools, while capability count has no such ceiling. Discover with list_operations (use detail=true to get parameters and worked examples), then call it here. Arguments are validated against the catalog BEFORE anything runs — unknown operat…

ParameterTypeDescription
arguments *object
operation *string

server_info

MapSmith version, licensing, and available engines.