🪟 Windows TippsPixel-Smartphones haben soeben ein riesiges Update erhalten(17.09.2026 um 10:32 Uhr)
🪟 Windows TippsAus alt mach (fast wie) neu: Stadionbeschallung Aachener Tivoli(17.09.2026 um 10:30 Uhr)
🪟 Windows ServerLenovo modernisiert Virtualisierungsinfrastruktur(17.09.2026 um 09:06 Uhr)
🤖 Android TippsAus alt mach (fast wie) neu: Stadionbeschallung Aachener Tivoli(17.09.2026 um 10:30 Uhr)
🕵️ SicherheitslückenCVE-2026-81165 | Drupal Blazy Module up to 3.0.18 improper authorization(17.09.2026 um 10:33 Uhr)
🪟 Windows TippsPixel-Smartphones haben soeben ein riesiges Update erhalten(17.09.2026 um 10:32 Uhr)
🪟 Windows TippsAus alt mach (fast wie) neu: Stadionbeschallung Aachener Tivoli(17.09.2026 um 10:30 Uhr)
🪟 Windows ServerLenovo modernisiert Virtualisierungsinfrastruktur(17.09.2026 um 09:06 Uhr)
🤖 Android TippsAus alt mach (fast wie) neu: Stadionbeschallung Aachener Tivoli(17.09.2026 um 10:30 Uhr)
🕵️ SicherheitslückenCVE-2026-81165 | Drupal Blazy Module up to 3.0.18 improper authorization(17.09.2026 um 10:33 Uhr)
🔧 Programmierung 🕛 vor 2 Monaten 3 Min Lesezeit
0

Point-in-polygon: one PostGIS query for geofencing, zones, and spatial lookups

↗ Quelle (dev.to)
🗣️ Stimme:

You've got a coordinate. You've got a pile of regions on a map. You need to know: which region does this point fall in, or is it inside one at all?



That single question hides inside a lot of features:




  • Geofencing: is this device or user inside the zone?

  • Service / delivery areas: does this address fall in our coverage?

  • Spatial lookups: which territory, district, or catchment owns this point?



They all reduce to one primitive: point in polygon. Learn it once and a whole class of "is this place inside or affected by X?" questions collapses into a single query. An example usage in real world context I have done in project is "is this address in a flood zone?" the exact same way. More on that at the end.



Let me walk through it.



Given a GeoJSON dataset:



Note: Most open spatial data ships as GeoJSON, a plain-text format for shapes. A region (a delivery area, a territory, a geofence) is just a polygon:




CODE
{
"type": "Feature",
"properties": { "name": "Zone A", "level": "high" },
"geometry": {
"type": "Polygon",
"coordinates":
[
[
[152.97, -27.47],
[152.98, -27.47],
[152.98, -27.48],
[152.97, -27.48],
[152.97, -27.47]
]
]
}
}






A geometry (the shape, as [lng, lat] points) plus properties. A full dataset is a FeatureCollection of thousands of these. GeoJSON is an open standard used worldwide, so once you can read one set of regions, you can read any of them.



Ingest the dataset into PostGIS




CODE
CREATE TABLE zones (
id serial PRIMARY KEY,
name text,
geom geometry(MultiPolygon, 4326)
);
-- load the GeoJSON with ogr2ogr (or shp2pgsql for shapefiles)






(4326 is WGS84, the standard lat/lng system GPS and GeoJSON use.)



The query:

Given a coordinate, you can use the ST_Intersects API to test if its inside any zone:




CODE
SELECT EXISTS (
SELECT 1
FROM zones
WHERE ST_Intersects(geom, ST_SetSRID(ST_MakePoint(:lng, :lat), 4326)
)
) AS inside_a_zone;






Want to know which zone, not just yes/no? Return it:




CODE
SELECT name 
FROM zones
WHERE ST_Intersects(geom, ST_SetSRID(ST_MakePoint(:lng, :lat), 4326));






And that is the whole pattern: spatial data plus one intersection test.



A few use cases I have used in reallife applications:




  1. Did the device enter this zone?

  2. Which district is this in?

  3. Is this address flooded?

  4. Can we deliver to this drop off point?



Same handful of lines every time, the formula almost never change. Point-in-polygon is most of "is this location inside or affected by X?" in geospatial software. And because GeoJSON is a global standard, it isn't region-specific: your delivery map, a US boundary set, a European zone layer, all the same approach.



Experience:

I lean on this pattern heavily at my company Property X-Ray, where most of the questions are based around address lookup runs and point-in-polygon against hundreds of overlapping overlays like flood, residential zoning, crime rate and more. The hard part is never the query, it's wrangling the data. But the primitive above is the whole foundation. Once point-in-polygon clicks, a huge category of "is this place inside something?" problems becomes one query.

Vollständiger Original-Artikel
Den kompletten Beitrag mit allen Details direkt auf dev.to lesen.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
2 Quellen
Axeos erhält ISO 9001:2015-Zertifizierung
1 Quelle
Amazon bietet Soundcore-In-Ears zum ersten Mal günstiger an: Mit ANC, Dolby Atmos & mehr Highlights
1 Quelle
Höllenmaschine HMX 6 im Halo-Design – passend zum Spiele-Release!
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Point-in-polygon: one PostGIS query for geofencing, zones, and spatial lookups

Thematisch verwandte Begriffe: Pointinpolygon, PostGIS, query, geofencing · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...