---
title: "Point-in-polygon query"
method: GET
path: "/v1/pip"
tags: ["Spatial Queries"]
---

# Point-in-polygon query

`GET /v1/pip`

## Request

- Base URL: `https://api.terranode.co`
- URL: `https://api.terranode.co/v1/pip`
- Auth: API key in header `x-api-key`

Test whether a point falls inside any polygon in the specified dataset. Returns all matching polygons with their properties. When no match is found, optionally returns the nearest polygon with distance.

## Query parameters

- `lat` number, required
- `lng` number, required
- `system_dataset` string
- `dataset` string
- `dataset_id` string, uuid
- `version` integer

## Response `200`

Query result.

- PipResponse
  - `match` boolean, required: True if the point is inside at least one polygon.
  - `matches` PipMatch[], required
    - `properties` FeatureProperties, required: Key-value properties from the matched feature. Keys and values depend on the dataset.
    - `on_boundary` boolean, required: True if the point lies exactly on the polygon boundary.
  - `nearest` PipNearest
    - `properties` FeatureProperties, required: Key-value properties from the matched feature. Keys and values depend on the dataset.
    - `distance_m` number, required: Distance to nearest edge in meters.
    - `distance_mi` number, required: Distance to nearest edge in miles.
  - `dataset` string, required
  - `version` integer, required
  - `latency_ms` number, required
  - `api_version` string, required
  - `semantics_version` string, required

## Other responses

- `400`: Invalid request parameters or body.
- `401`: Missing or invalid API key.
- `404`: Resource not found.
- `422`: Geometry type mismatch. The dataset's geometry type is incompatible with the requested operation (e.g., Point dataset used with PIP).
- `429`: Monthly request quota exceeded.
- `500`: Internal server error.

---

[API](https://skmtc.dev/terranode/apis/terranode-geospatial-api.md) · [All operations](https://skmtc.dev/terranode/apis/terranode-geospatial-api/llms.txt) · [OpenAPI document](https://skmtc.dev/terranode/apis/terranode-geospatial-api/revisions/bdd80613bc7a?raw)
