GeoLabSpatial SQL Workbench
Worked example

Join Points to Polygons in the Browser

This example uses GeoLab's built-in stores.csv and districts.geojson. It constructs point geometry from longitude and latitude, joins each point to a containing polygon, and keeps coordinates in the result for map rendering.

Point source
stores.csv
Polygon source
districts.geojson
Expected matches
9 coffee shops
Unmatched coffee shop
Park Espresso

1. Load the inputs

Open GeoLab and choose Load 3-file demo. The browser creates relations named stores, districts, and roads. Only the first two are needed for this query.

RelationGeometry
storesPoint geometry constructed from lng and lat
districtsPolygon geometry read from GeoJSON

2. Run the join

Point-in-polygon joinsql
SELECT
  s.id,
  s.name,
  s.category,
  s.lng,
  s.lat,
  d.name AS district
FROM stores AS s
JOIN districts AS d
  ON ST_Within(
    ST_Point(s.lng, s.lat),
    d.geometry
  )
WHERE s.category = 'coffee'
ORDER BY s.id;

3. Check the expected output

DistrictMatched coffee shops
North MarketJuniper Coffee; Field Notes Cafe; North Star Roasters
River QuarterAtlas Coffee; Cedar & Steam; Seven Seeds
Old TownWorkshop Coffee; Common Ground; Ember Coffee

NotePark Espresso is a coffee shop but lies in the gap between the sample district polygons, so the inner join correctly omits it.

4. Interpret edge cases

  • A point exactly on a polygon boundary may not satisfy ST_Within.
  • Overlapping polygons can return more than one row per point.
  • Different CRSs must be transformed explicitly before comparing geometry.
  • This example demonstrates SQL semantics; it does not create or benchmark a spatial index.

Sources and scope

These links document the product behavior summarized above. GeoLab-specific claims are limited to the current public v0.1.0 implementation.

  1. GeoLab demo data and queryThe exact sample files and query used here.
  2. DuckDB Spatial functionsOfficial reference for geometry constructors, predicates, and measurements.