π§οΈ Cropped precision
Each polygon is pre-clipped to the exact circular area you queried β no post-processing needed on your side.
β‘ Binary-efficient
Protobuf encoding cuts payload size significantly compared to JSON, making it ideal for mobile and embedded clients.
πΊοΈ GeoJSON-ready
Two decode steps are all it takes to go from raw bytes to shapes you can drop straight into geojson.io or Mapbox.
What the endpoint returns
POST /v1/precipitations/geometry responds with a raw binary body (Content-Type: application/x-protobuf).
The bytes encode a PrecipitationFeatureCollection message β a list of PrecipitationFeature items, each carrying a cropped MultiPolygon geometry and typed precipitation properties.
Proto schema π
Below are the proto message definitions used by iklim.co for this endpoint.Decoding & converting to GeoJSON π οΈ
Why two steps? GeoJSON is a JSON text format (RFC 7946) β it has no official protobuf schema. Its coordinates are bare nested arrays (
[[lng, lat], ...]), which protobuf cannot represent without a named wrapper message. iklim.coβs binary schema uses typed messages (Coordinate, Ring, PolygonShape, β¦) optimised for compact encoding, so a structural reshaping step is always required after decoding.- Step-by-step guide πͺ
- All-in-one snippet β‘
- GeoJSON output π
1
Install protobufjs π¦
2
Fetch the binary response π
Tell
fetch to read the response as an ArrayBuffer, then wrap it in a Uint8Array for the proto decoder.3
Decode the protobuf bytes π
Load At this point
geojson.proto and decode the bytes into a JavaScript object.fc looks like:4
Convert to standard GeoJSON πΊοΈ
Transform the decoded object into RFC 7946-compliant GeoJSON.