GeoLabSpatial SQL Workbench
Capability guide

Spatial Join in the Browser

GeoLab loads each selected file as a relation in one browser-local DuckDB connection. Standard SQL joins can therefore combine sources, while predicates such as ST_Within determine their spatial relationship.

Example inputs
CSV points + GeoJSON polygons
Predicate
ST_Within
Execution
Current browser session
Demo result
9 matched coffee shops

The join model

A spatial join is still a SQL join: every matching pair becomes a result row. The difference is that the ON clause evaluates geometry rather than an equality key. In the built-in demo, store coordinates become points and district features provide polygons.

Example query

Assign coffee shops to districtssql
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;

How to read the result

The demo contains ten coffee shops, but the query returns nine matched rows. Park Espresso falls in the gap between the demo polygons, so it has no matching district. This is a data coverage result, not an automatic indication of invalid SQL.

  • ST_Within uses strict interior semantics; a point on a polygon boundary may not match.
  • Overlapping polygons may produce more than one row for a point.
  • Keeping lng and lat in the SELECT list lets GeoLab render the joined result as points.
  • Selecting district geometry instead would render the polygon side of the result.

Performance and correctness boundaries

  • GeoLab does not claim to create or tune a spatial index for the join.
  • Topology repair, CRS alignment, and predicate choice remain explicit analysis decisions.
  • The practical data size is constrained by browser memory, with a 1,000,000-feature render cap.

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 queryThe exact three-source demo and SQL used by the application.
  2. DuckDB Spatial functionsOfficial reference for geometry constructors, predicates, and measurements.
  3. DuckDB FROM and JOIN syntaxOfficial SQL join semantics.