CSV Spatial SQL in the Browser
GeoLab reads a selected CSV into DuckDB-WASM, recognizes a supported geometry representation, and runs SQL in the same browser tab. The file is not sent to a GeoLab application backend, and the resulting table is not persisted after refresh.
- Input
- Local .csv
- Execution
- DuckDB-WASM in a Web Worker
- Geometry
- WKT/EWKT or known coordinate pairs
- Persistence
- Current browser session only
What counts as a spatial CSV
A CSV becomes spatial when GeoLab can identify either a WKT/EWKT text column or a supported pair of numeric coordinate columns. Recognition is based on column values and known coordinate names, not on a generic promise that every CSV contains usable geometry.
| Representation | Recognized form | CRS behavior |
|---|---|---|
| Longitude and latitude | lng/lat, lon/lat, longitude/latitude | Treated as EPSG:4326 |
| Generic coordinates | x/y | CRS remains unknown |
| Geometry text | WKT or EWKT in a text column | A consistent EWKT SRID is reported; no automatic reprojection |
Browser-local import pipeline
- The selected file is registered in DuckDB-WASM's browser file system.
- GeoLab creates a local table with read_csv_auto using the header row and a full-file type sample.
- The first data sample is inspected for WKT/EWKT or known coordinate pairs.
- SQL results with recognizable geometry become map layers; non-spatial results open as a table preview.
Example: filter CSV points and construct geometry
The built-in stores CSV uses lng and lat columns. Keeping those columns in the result is enough for GeoLab to render points; constructing an explicit geometry also makes the spatial intent portable to later predicates.
SELECT
id,
name,
category,
lng,
lat,
ST_Point(lng, lat) AS geometry
FROM stores
WHERE category = 'coffee'
ORDER BY id;Where the workflow stops
- GeoLab does not automatically transform projected x/y coordinates to WGS84.
- The application does not edit the source CSV or export query results in v0.1.0.
- Spatial rendering is capped at 1,000,000 features; attribute previews show at most 200 rows.
- Imported tables and saved workspace layers disappear when the page is refreshed.
NoteUse explicit DuckDB Spatial transformation functions when the input CRS is known and differs from the map's WGS84 coordinates.
Sources and scope
These links document the product behavior summarized above. GeoLab-specific claims are limited to the current public v0.1.0 implementation.
- GeoLab READMESupported inputs, browser execution model, limits, and privacy boundaries.
- DuckDB CSV overviewOfficial CSV reader and type detection documentation.
- DuckDB Spatial documentationOfficial overview of the Spatial extension used by GeoLab.