POI polygon-to-polygon join
UseST_Intersects to join two datasets that both have POI geometry columns. This finds all records from one dataset whose geographic polygon overlaps with polygons in another dataset.
- Both datasets must have a
geographic_poi.poiattribute mapped through Rosetta Stone ST_Intersectsreturns true when the two geometries share any area in common- Select non-geometry columns only---latitude, longitude, timestamps, and identifiers
Point-to-polygon join
When one dataset has raw coordinates instead of POI polygons, useST_SafePoint and ST_Circle to create a geometry on the fly, then join with ST_Intersects.
ST_Circle takes a point and a radius in meters. In this example, each observation is expanded into a 50-meter circle and checked for overlap with the POI polygons.
Combining geospatial and temporal filters
Most geospatial queries also need time-based filtering. Always include both anevent_timestamp range and a nio_last_modified_at filter to scope the data appropriately.
event_timestampfilters the actual observation timenio_last_modified_atensures query efficiency by limiting the data scan window
Common pitfalls
GEOMETRY type cannot be in SELECT
Geometry columns cannot be returned in query results. Use them only in JOIN conditions or WHERE clauses. This fails:Argument order in ST_Intersects
Place the reference/POI dataset geometry as the first argument and the observation geometry as the second argument. Reversing the order can cause internal errors.Always use _rosetta_stone
Access columns through the_rosetta_stone path. Queries that omit _rosetta_stone may appear to work in some cases, but this is not a supported pattern and will produce unreliable results.
Related content
Location Data
Understanding location polygons and geospatial formats
Geospatial Functions
ST_SafePoint, ST_Circle, ST_Intersects, and more
Complex Join Patterns
Advanced join recipes for multi-dataset scenarios
Unsupported Type Errors
Resolving GEOMETRY type errors in SELECT statements

