Cut holes out of a polygon: the buildable part of a parcel once setbacks are removed, the
Cut holes out of a polygon: the buildable part of a parcel once setbacks are removed, the land outside a protected area, the part of a route not already covered. Order is significant, so this is the one overlay op where swapping the operands gives a different answer. Subtracting everything answers geojson:null with empty:true, a real answer rather than an error. Send a FeatureCollection of Polygons or MultiPolygons; the first member in document order has every later member subtracted from it. The answer is a single Feature, or null with empty:true when nothing survives. Clipping is planar in longitude/latitude, so edges are straight in degrees rather than geodesics. The 2000-position cap is CPU rather than bandwidth: the sweep-line overlay is quadratic on self-intersecting input. Input is EPSG:4326 only. Limits: 2000 positions across all members, 1 MiB request body, and at least two polygonal geometries or the call is refused.
Provider
api.geoprimitives.dev · discovered, not yet claimed by its owner
Payment (x402 accepts[])
[
{
"scheme": "exact",
"network": "eip155:8453",
"payTo": "0x76A51b5Dd3729950B3b60c17f19252d221968FCe",
"asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"amount": "10000",
"maxTimeoutSeconds": 300
}
]Output schema
{
"bazaar": {
"info": {
"input": {
"body": {
"geojson": {
"features": [
{
"geometry": {
"coordinates": [
[
[
-150,
61
],
[
-149.9,
61
],
[
-149.9,
61.1
],
[
-150,
61.1
],
[
-150,
61
]
]
],
"type": "Polygon"
},
"properties": null,
"type": "Feature"
},
{
"geometry": {
"coordinates": [
[
[
-149.95,
61.05
],
[
-149.85,
61.05
],
[
-149.85,
61.15
],
[
-149.95,
61.15
],
[
-149.95,
61.05
]
]
],
"type": "Polygon"
},
"properties": null,
"type": "Feature"
}
],
"type": "FeatureCollection"
}
},
"bodyType": "json",
"method": "POST",
"type": "http"
},
"output": {
"example": {
"empty": false,
"geojson": {
"geometry": {
"coordinates": [
[
[
-150,
61
],
[
-149.9,
61
],
[
-149.9,
61.05
],
[
-149.95,
61.05
],
[
-149.95,
61.1
],
[
-150,
61.1
],
[
-150,
61
]
]
],
"type": "Polygon"
},
"properties": null,
"type": "Feature"
},
"inputGeometries": 2,
"inputVertices": 10,
"notes": [
"The first geometry in document order had every later one subtracted from it.",
"Vertices are treated as planar in longitude/latitude, which is what every polygon-clipping library does. Edges are straight in degrees, not geodesics; on edges spanning more than a degree or so the two differ."
],
"op": "difference",
"outputVertices": 7
},
"type": "json"
}
},
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"input": {
"additionalProperties": false,
"properties": {
"body": {
"additionalProperties": false,
"properties": {
"geojson": {
"description": "A GeoJSON FeatureCollection or GeometryCollection holding two or more Polygons or MultiPolygons in EPSG:4326. The first is the minuend and every later one is subtracted from it. At most 2000 positions across all members. Anything non-polygonal is rejected.",
"type": "object"
}
},
"required": [
"geojson"
],
"type": "object"
},
"bodyType": {
"enum": [
"json",
"form-data",
"text"
],
"type": "string"
},
"method": {
"enum": [
"POST"
],
"type": "string"
},
"type": {
"const": "http",
"type": "string"
}
},
"required": [
"type",
"method",
"bodyType",
"body"
],
"type": "object"
},
"output": {
"properties": {
"example": {
"type": "object"
},
"type": {
"type": "string"
}
},
"required": [
"type"
],
"type": "object"
}
},
"required": [
"input"
],
"type": "object"
}
}
}Use it
curl
curl "https://api.geoprimitives.dev/v1/geometry/difference" # -> 402 Payment Required, accepts[] lists how to pay # retry with a PAYMENT-SIGNATURE (or PAYMENT header) once paid
JavaScript
const res = await fetch("https://api.geoprimitives.dev/v1/geometry/difference");
if (res.status === 402) {
const { accepts } = await res.json();
// pay one of accepts[] via an x402 client, then retry with the payment header
}Python
import httpx
res = httpx.get("https://api.geoprimitives.dev/v1/geometry/difference")
if res.status_code == 402:
accepts = res.json()["accepts"]
# pay one of accepts[] via an x402 client, then retry with the payment headerMachine-readable
Everything on this page is also available as clean JSON at /resources/6759.json, and this resource appears in /discovery/resources and /discovery/search.