Tweaked SpatiaLite CLI docs, refs #398

This commit is contained in:
Simon Willison 2022-02-15 17:06:49 -08:00
commit 3e5a4f60cc
2 changed files with 13 additions and 1 deletions

View file

@ -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

View file

@ -1984,13 +1984,14 @@ Since `SpatiaLite <https://www.gaia-gis.it/fossil/libspatialite/index>`__ is com
$ sqlite-utils memory "select spatialite_version()" --load-extension=spatialite
[{"spatialite_version()": "4.3.0a"}]
.. _cli_spatialite:
SpatiaLite helpers
==================
`SpatiaLite <https://www.gaia-gis.it/fossil/libspatialite/home>`_ adds geographic capability to SQLite (similar to how PostGIS builds on PostgreSQL). The `SpatiaLite cookbook <http://www.gaia-gis.it/gaia-sins/spatialite-cookbook-5/index.html>`_ 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