1
0
mirror of https://github.com/django/django.git synced 2024-12-23 17:46:27 +00:00
django/docs/ref/contrib/gis/install/spatialite.txt
Tobias Kunze 4a954cfd11 Fixed #30573 -- Rephrased documentation to avoid words that minimise the involved difficulty.
This patch does not remove all occurrences of the words in question.
Rather, I went through all of the occurrences of the words listed
below, and judged if they a) suggested the reader had some kind of
knowledge/experience, and b) if they added anything of value (including
tone of voice, etc). I left most of the words alone. I looked at the
following words:

- simply/simple
- easy/easier/easiest
- obvious
- just
- merely
- straightforward
- ridiculous

Thanks to Carlton Gibson for guidance on how to approach this issue, and
to Tim Bell for providing the idea. But the enormous lion's share of
thanks go to Adam Johnson for his patient and helpful review.
2019-09-06 13:27:46 +02:00

131 lines
3.9 KiB
Plaintext

=====================
Installing SpatiaLite
=====================
`SpatiaLite`__ adds spatial support to SQLite, turning it into a full-featured
spatial database.
First, check if you can install SpatiaLite from system packages or binaries.
For example, on Debian-based distributions that package SpatiaLite 4.2+, try to
install the ``libsqlite3-mod-spatialite`` package. For older releases install
``spatialite-bin``.
For macOS, follow the :ref:`instructions below<spatialite_macos>`.
For Windows, you may find binaries on the `Gaia-SINS`__ home page.
In any case, you should always be able to :ref:`install from source
<spatialite_source>`.
__ https://www.gaia-gis.it/fossil/libspatialite
__ https://www.gaia-gis.it/gaia-sins/
.. _spatialite_source:
Installing from source
======================
:doc:`GEOS and PROJ.4</ref/contrib/gis/install/geolibs>` should be installed
prior to building SpatiaLite.
SQLite
------
Check first if SQLite is compiled with the `R*Tree module`__. Run the sqlite3
command line interface and enter the following query::
sqlite> CREATE VIRTUAL TABLE testrtree USING rtree(id,minX,maxX,minY,maxY);
If you obtain an error, you will have to recompile SQLite from source. Otherwise,
skip this section.
To install from sources, download the latest amalgamation source archive from
the `SQLite download page`__, and extract::
$ wget https://www.sqlite.org/YYYY/sqlite-amalgamation-XXX0000.zip
$ unzip sqlite-amalgamation-XXX0000.zip
$ cd sqlite-amalgamation-XXX0000
Next, run the ``configure`` script -- however the ``CFLAGS`` environment variable
needs to be customized so that SQLite knows to build the R*Tree module::
$ CFLAGS="-DSQLITE_ENABLE_RTREE=1" ./configure
$ make
$ sudo make install
$ cd ..
__ https://www.sqlite.org/rtree.html
__ https://www.sqlite.org/download.html
.. _spatialitebuild:
SpatiaLite library (``libspatialite``)
--------------------------------------
Get the latest SpatiaLite library source bundle from the
`download page`__::
$ wget https://www.gaia-gis.it/gaia-sins/libspatialite-sources/libspatialite-X.Y.Z.tar.gz
$ tar xaf libspatialite-X.Y.Z.tar.gz
$ cd libspatialite-X.Y.Z
$ ./configure
$ make
$ sudo make install
.. note::
For macOS users building from source, the SpatiaLite library *and* tools
need to have their ``target`` configured::
$ ./configure --target=macosx
__ https://www.gaia-gis.it/gaia-sins/libspatialite-sources/
.. _spatialite_macos:
macOS-specific instructions
==============================
To install the SpatiaLite library and tools, macOS users can choose between
:ref:`kyngchaos` and `Homebrew`_.
KyngChaos
---------
First, follow the instructions in the :ref:`kyngchaos` section.
When creating a SpatiaLite database, the ``spatialite`` program is required.
However, instead of attempting to compile the SpatiaLite tools from source,
download the `SpatiaLite Tools`__ package for macOS, and install ``spatialite``
in a location available in your ``PATH``. For example::
$ curl -O https://www.kyngchaos.com/files/software/frameworks/Spatialite_Tools-4.3.zip
$ unzip Spatialite_Tools-4.3.zip
$ cd Spatialite\ Tools/tools
$ sudo cp spatialite /Library/Frameworks/SQLite3.framework/Programs
Finally, for GeoDjango to be able to find the KyngChaos SpatiaLite library,
add the following to your ``settings.py``::
SPATIALITE_LIBRARY_PATH='/Library/Frameworks/SQLite3.framework/SQLite3'
__ https://www.kyngchaos.com/software/frameworks/
Homebrew
--------
`Homebrew`_ handles all the SpatiaLite related packages on your behalf,
including SQLite, SpatiaLite, PROJ, and GEOS. Install them like this::
$ brew update
$ brew install spatialite-tools
$ brew install gdal
Finally, for GeoDjango to be able to find the SpatiaLite library, add the
following to your ``settings.py``::
SPATIALITE_LIBRARY_PATH='/usr/local/lib/mod_spatialite.dylib'
.. _Homebrew: https://brew.sh/