From 3e5a4f60cc07e38113e522e5f1d09db35626affc Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Tue, 15 Feb 2022 17:06:49 -0800 Subject: [PATCH] Tweaked SpatiaLite CLI docs, refs #398 --- docs/cli-reference.rst | 6 ++++++ docs/cli.rst | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/cli-reference.rst b/docs/cli-reference.rst index 5497259..19b714b 100644 --- a/docs/cli-reference.rst +++ b/docs/cli-reference.rst @@ -56,6 +56,8 @@ This page lists the ``--help`` for every ``sqlite-utils`` CLI sub-command. "insert-files": "cli_insert_files", "analyze-tables": "cli_analyze_tables", "convert": "cli_convert", + "add-geometry-column": "cli_spatialite", + "create-spatial-index": "cli_spatialite_indexes", } commands.sort(key = lambda command: go_first.index(command) if command in go_first else 999) cog.out("\n") @@ -1231,6 +1233,8 @@ See :ref:`cli_drop_view`. add-geometry-column =================== +See :ref:`cli_spatialite`. + :: Usage: sqlite-utils add-geometry-column [OPTIONS] DB_PATH TABLE COLUMN_NAME @@ -1258,6 +1262,8 @@ add-geometry-column create-spatial-index ==================== +See :ref:`cli_spatialite_indexes`. + :: Usage: sqlite-utils create-spatial-index [OPTIONS] DB_PATH TABLE COLUMN_NAME diff --git a/docs/cli.rst b/docs/cli.rst index cadcbf1..8ec3f9e 100644 --- a/docs/cli.rst +++ b/docs/cli.rst @@ -1984,13 +1984,14 @@ Since `SpatiaLite `__ is com $ sqlite-utils memory "select spatialite_version()" --load-extension=spatialite [{"spatialite_version()": "4.3.0a"}] +.. _cli_spatialite: SpatiaLite helpers ================== `SpatiaLite `_ adds geographic capability to SQLite (similar to how PostGIS builds on PostgreSQL). The `SpatiaLite cookbook `_ is a good resource for learning what's possible with it. -You can convert an existing table to a geographic table by adding a geometry column, use the `sqlite-utils add-geometry-column` command:: +You can convert an existing table to a geographic table by adding a geometry column, use the ``sqlite-utils add-geometry-column`` command:: $ sqlite-utils add-geometry-column spatial.db locations geometry --type POLYGON --srid 4326 @@ -2009,6 +2010,11 @@ Eight (case-insensitive) types are allowed: * GEOMETRYCOLLECTION * GEOMETRY +.. _cli_spatialite_indexes: + +Adding spatial indexes +---------------------- + Once you have a geometry column, you can speed up bounding box queries by adding a spatial index:: $ sqlite-utils create-spatial-index spatial.db locations geometry