From 37f8361c6f7b3eeaa351c0cd93b6db1fdd2744ab Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sat, 26 May 2018 11:04:09 -0700 Subject: [PATCH] Initial documentation on using SpatiaLite https://datasette.readthedocs.io/en/latest/spatialite.html --- docs/index.rst | 1 + docs/spatialite.rst | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 docs/spatialite.rst diff --git a/docs/index.rst b/docs/index.rst index 5e20be4f..031ff0fa 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -21,6 +21,7 @@ Contents sql_queries facets full_text_search + spatialite metadata config introspection diff --git a/docs/spatialite.rst b/docs/spatialite.rst new file mode 100644 index 00000000..935bfc45 --- /dev/null +++ b/docs/spatialite.rst @@ -0,0 +1,39 @@ +.. _spatialite: + +SpatiaLite +========== + +The `SpatiaLite module `_ for SQLite adds features for handling geographic and spatial data. For an example of what you can do with it, see the tutorial `Building a location to time zone API with SpatiaLite, OpenStreetMap and Datasette `_. + +To use it with Datasette, you need to install the ``mod_spatialite`` dynamic library. This can then be loaded into Datasette using the ``--load-extension`` command-line option. + +Installing SpatiaLite on OS X +----------------------------- + +The easiest way to install SpatiaLite on OS X is to use `Homebrew `_. + +:: + + brew update + brew install spatialite-tools + +This will install the ``spatialite`` command-line tool and the ``mod_spatialite`` dynamic library. + +You can now run Datasette like so:: + + datasette --load-extension=/usr/local/lib/mod_spatialite.dylib + +Installing SpatiaLite on Linux +------------------------------ + +SpatiaLite is packaged for most Linux distributions. + +:: + + apt install spatialite-bin libsqlite3-mod-spatialite + +Depending on your distribution, you should be able to run Datasette something like this:: + + datasette --load-extenison=/usr/lib/x86_64-linux-gnu/mod_spatialite.so + +If you are unsure of the location of the module, try running ``locate mod_spatialite`` and see what comes back.