Parallel icon
Size icon
Assert icon
Concat icon
Query icon
IonToCsv icon
Webhook icon

Enrich GPS points with PostGIS zones and explicit overlap handling

Assign GeoJSON points to PostGIS zones. Include boundaries, reject invalid geometry and preserve ambiguous or unmatched points in a reusable CSV.

Categories
Data

Assign GPS events to service areas without silently discarding points or choosing the first overlapping polygon. Native PostgreSQL and serialization tasks produce a CSV that keeps every input event and its matching zone candidates.

How it works

  1. Upload two GeoJSON files manually or send existing Kestra file URIs through the keyed webhook.
  2. Bound files to 1 MiB, copy them into this execution, then validate both in parallel with PostGIS.
  3. Reject invalid collections, geometries, duplicate IDs, unsupported CRS and coordinates.
  4. Join with ST_Covers, which includes polygon boundaries. Export one CSV row per event: MATCHED for one zone, UNMATCHED for none, AMBIGUOUS for multiple zones.

What you get

  • A downloadable assignments CSV with coordinates, status, match count and sorted candidate zone IDs.
  • assigned_zone is filled only for a unique match. Shared boundaries and overlaps stay explicit.
  • Read-only database operations; no table creation, geometry repair or source mutation.

Who it's for

  • Data engineers enriching delivery, fleet or sensor events with operational zones.

Why orchestrate this with Kestra

Parallel validation must finish before the spatial join starts. Each failed precondition has its own task state, and the CSV stays attached to the execution for downstream loading. Credentials and webhook authentication stay in secrets.

Prerequisites

  • PostgreSQL with PostGIS 3+, PostgreSQL JDBC and serialization plugins; no Docker runner.
  • RFC 7946 longitude/latitude GeoJSON FeatureCollections, without crs members. Use unique string id values on Features, not IDs hidden inside properties.
  • 1-1000 Point events and 1-100 Polygon/MultiPolygon zones; 2D, nonempty, valid geometry, at most 10,000 vertices per feature and at most 1 MiB per file.
  • Local planar zones that do not cross the antimeridian or enclose a pole. This uses geometry, not geodesic geography. Reproject non-WGS84 sources before use.

Secrets

  • POSTGRES_JDBC_URL: JDBC URL of a database with PostGIS already installed.
  • POSTGRES_USERNAME: Role with connection and PostGIS function execution access.
  • POSTGRES_PASSWORD: Password for that role.
  • GEO_WEBHOOK_KEY: Key protecting the batch webhook.

Quick start

  1. Configure secrets and prepare points/zones GeoJSON with stable Feature IDs.
  2. Execute manually and upload both files; download assignments from Outputs.
  3. Check AMBIGUOUS/UNMATCHED rows before loading assignments. A producer can call the keyed webhook with JSON fields points and zones containing existing kestra:///... GeoJSON file URIs accessible to this flow in the same tenant.

How to extend

  • Load unique assignments into a warehouse and route other statuses for zone review.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.