Files
GeoLibre/docs/tutorials/spatial-sql.md
T
Qiusheng Wuandgiswqs 6c9f26dc1a docs: add User Guide and Tutorials (complete v1.0 documentation roadmap) (#194)
* docs: add User Guide and Tutorials, completing the v1.0 documentation roadmap

Add a comprehensive feature-by-feature User Guide (interface, projects,
adding data, layers, styling, attribute table, controls, processing, SQL
workspace, data integrations, plugins, settings, embedding) and seven
end-to-end Tutorials. Restructure the docs nav into User Guide, Tutorials,
and Reference sections, link the new sections from the home page, and check
off the final v1.0 roadmap item.

Screenshots are hosted on Cloudflare R2 (data.geolibre.app/images) and
referenced by URL, not committed to the repo.

* docs: note the live demo is GitHub Pages-hosted, browser-only, and does not track users

* docs: make sidebar section headers stand out (User Guide, Tutorials, Reference)

* docs: align README and User Guide/Tutorials for consistency

- Link the hosted User Guide and Tutorials from the README Documentation section
- Standardize menu navigation to the arrow separator used by the rest of the docs
- Fix SQL Workspace examples to use the dataset's real columns (NAME, POP_EST,
  GDP_MD_EST) and geometry column (geom), and bare-URL FROM, matching the
  in-app sample queries and the README

* docs: refresh 'What GeoLibre does today' cards to current functionality

Drop the removed sample-data plugin and surface the plugin marketplace; replace
the stale 'roadmap toward DuckDB Spatial and a sidecar' processing card with the
shipped Conversion menu and Whitebox toolbox; broaden the data-format and
map-workspace cards to current sources, data-driven styling, sharing, and the
on-map component tools.

* chore: release v1.0.0

Bump all workspace packages, the Tauri desktop app (package.json, tauri.conf.json,
Cargo.toml/Cargo.lock), and the Python sidecar to 1.0.0, and sync package-lock.json.

Update the docs and README for the v1.0 release: mark v1.0 as current on the
roadmap, retitle the README features section, rewrite the home page Project
status for a stable v1.0, and refresh the v0.9.0 version labels in the
architecture and project-format pages and the plugin manifest examples.

* docs: add screenshots to text-only User Guide and tutorial pages

Add dark-theme screenshots to Projects, Managing Layers, Styling Layers,
Settings, Data Integrations, and Embedding & Sharing (every User Guide page now
has at least one), plus the Add Vector panel in the Your First Map tutorial.
Hosted on R2 and referenced by URL.

* Address Claude and CodeRabbit review feedback

- settings.md, projects.md, sharing-embedding.md: move the Share.GeoLibre API
  token to the Environment Variables section (it lives in the Environment tab,
  not Project Settings) and use the real field name; list the read-only Project
  file/format fields; fix "Restrict map bounds" and "Use Current View" labels
- embedding.md, sharing-embedding.md: add iframe title and
  allow="fullscreen; geolocation"; escape & as & in iframe src attributes
- embedding.md: note icon and icon-only as toolbar aliases
- interface.md: separate the rotate (right-drag) and tilt (Ctrl/Cmd-drag) gestures
- processing.md: note the menu order differs from the page grouping; note Union
  drops attributes; mark Vector to FlatGeobuf as Hilbert-sorted
- cloud-native-data.md: clarify the Stream GeoParquet hint (spatial/Hilbert
  row-group sorting, not a bounding-box column)
- plugins.md: manifests allow HTTPS or HTTP on loopback, not HTTPS-only
- spatial-sql.md: note the sample columns are Natural Earth fields
- extra.css: comment that the nav selectors target Material internals (9.x)

* Address second round of Claude review feedback

- spatial-sql.md: note ST_Area returns square degrees on EPSG:4326 data
  (ranking is valid; use ST_Area_Spheroid for km2)
- spatial-sql.md: clarify the bare-URL FROM shorthand is a SQL Workspace
  convenience, not standard DuckDB CLI syntax

* Address third round of Claude review feedback

- spatial-sql.md: note the sample file's geometry column is `geom` and show
  DESCRIBE SELECT * FROM 'url' to discover columns in other datasets

* Address fourth round of Claude review feedback

- vector-analysis.md: mirror the Union "attributes are not preserved" caveat from
  processing.md (verified: both the Turf.js client and the GeoPandas sidecar drop
  attributes for Union)

* Address Claude review feedback (round 6)

- processing.md: note Intersection merges attributes from both layers and
  Difference keeps input attributes (verified in vector-tools.ts)
- data-integrations.md: move GeoAgent out of "Time series and comparison" into
  its own "AI analysis" section
- map-controls.md: correct the tilt gesture description (Ctrl/Cmd-drag tilts into
  a perspective view, not a 3D look-around mode)
- adding-data.md: note that GeoParquet Layer opens the same Add Vector panel as
  Vector Layer

* Address review feedback: soften the live-demo "secure" claim

- embedding.md, index.md: replace the absolute "it is secure" assertion with
  concrete, verifiable statements (no analytics, no server account, client-side
  processing, no tracking), per maintainer decision and two bot reviews

* Address Claude review feedback: sync Union note with the tutorial

- processing.md: add "on either engine" to the Union attribute note so it matches
  the wording in vector-analysis.md

---------

Co-authored-by: giswqs <giswqs@users.noreply.github.com>
2026-06-09 22:19:48 -04:00

2.7 KiB

Spatial SQL

The SQL Workspace lets you analyze data with DuckDB Spatial SQL and add the results to the map. It runs on DuckDB-WASM, so it works in the browser as well as the desktop app. Open it from Processing → SQL Workspace.

1. Query a loaded layer

Every loaded vector layer is a queryable table. Load the sample countries layer (see Your First Map), then run:

SELECT NAME, CONTINENT, GDP_MD_EST
FROM countries
ORDER BY GDP_MD_EST DESC
LIMIT 10;

Click Run to see the ten countries with the highest estimated GDP.

!!! note "Sample dataset columns" NAME, CONTINENT, POP_EST, and GDP_MD_EST are Natural Earth field names in the sample countries.parquet, whose geometry column is geom. A different dataset will have its own column names. To discover them, run DESCRIBE SELECT * FROM 'your-file-url' first.

2. Query a remote file directly

You do not have to load a file first. The Workspace detects a bare URL in a FROM clause and wraps it in the right reader automatically, then streams the file over HTTP range requests so you do not download it in full. This bare-URL shorthand is a SQL Workspace convenience; in the standard DuckDB CLI you would write read_parquet('https://...') explicitly.

SELECT COUNT(*) AS n
FROM https://data.source.coop/giswqs/opengeos/countries.parquet;

3. Use spatial functions

The spatial extension is loaded, so ST_* functions are available. For example, compute area and keep the geom column so the result can be mapped:

-- area is in square degrees because the data is in EPSG:4326;
-- the ranking is valid, but use ST_Area_Spheroid(geom) / 1e6 for km2.
SELECT NAME, ST_Area(geom) AS area, geom
FROM https://data.source.coop/giswqs/opengeos/countries.parquet
WHERE CONTINENT = 'Africa'
ORDER BY area DESC;

4. Add the result to the map

When a query returns a geometry column, use add to map to create a new layer from the result, optionally naming it. The result layer supports identify, selection, and the attribute table like any vector layer, and you can add several result layers at once.

5. Export

Export the query result as CSV or GeoParquet straight from the workspace. See SQL Workspace.

!!! tip "Sample queries and history" Use the Sample queries menus to start from a working query, and the history to rerun a previous one.

Next steps