DOCS / GETTING STARTED / INTRODUCTION

Introduction

TerraQuerry is a spatial reasoning layer that sits between your geospatial data and your users (or agents). This guide walks through connecting a dataset, asking your first question, and reading the cited geometry behind every answer.

Heads up. TerraQuerry is in private beta. The endpoints below are stable, but rate limits and pricing are subject to change before GA. Request access →

Quickstart

Install the SDK, point it at a dataset, and ask a question. Three steps.

1$pip install terraquerry
2from terraquerry import Client
3tq = Client(api_key="tq_live_…")
4tq.connect("postgres://gis:…@db.yourco/gis")
5r = tq.ask("Parcels in flood zone within 2km of Cedar River")
6r.geojson  # FeatureCollection — drop into any map
7r.summary  # "1,247 parcels · 412 acres · est. value $890M"
8r.plan     # the SQL the planner ran, for audit

Core concepts

API reference · POST /v1/ask

POST https://api.terraquerry.ai/v1/ask RATE 60 / min
REQUEST
qstringNatural-language question. Max 4 KB.
datasetstring?Slug of a connected dataset. Defaults to your workspace's primary.
formatenum?geojson · parquet · mvt — default geojson.
crsstring?EPSG code for output. Default EPSG:4326.
citebool?Return touched rows + plan. Default true.
RESPONSE 200
1{
2  "summary": "1,247 parcels · 412 acres · $890M aev",
3  "geojson": { "type": "FeatureCollection", … },
4  "plan": {
5    "steps": [
6      { "op": "ST_DWithin", "args": ["cedar_river", 2000] },
7      { "op": "ST_Intersects", "args": ["flood_100yr"] }
8    ],
9    "sql": "SELECT p.* FROM parcels p …"
10  },
11  "meter": { "qu": 1.4, "ms": 312 }
12}

Spatial operators

The planner has direct access to the following primitives. Most queries decompose into 2–4 of these.

ST_Intersectsgeometric overlap
ST_Containsfully inside
ST_Withincontained by
ST_DWithinwithin distance
ST_Buffergeometric buffer
ST_Distancegeodesic / projected
ST_KNNk-nearest
ST_Uniongeometry merge
ST_Differenceset difference
ST_Centroidgeometric center
ST_ConvexHullouter hull
Isochronetravel-time polygon
Viewshedline-of-sight
ZonalStatsraster × polygon
NDVIvegetation index
DBSCANdensity clusters
PAGE 1 OF 24 · NEXT: QUICKSTART Quickstart →