2012-10-19 16:19:17 +00:00
|
|
|
===============================
|
|
|
|
Installing Geospatial libraries
|
|
|
|
===============================
|
|
|
|
|
|
|
|
GeoDjango uses and/or provides interfaces for the following open source
|
|
|
|
geospatial libraries:
|
|
|
|
|
2023-06-30 04:03:08 +00:00
|
|
|
======================== ==================================== ================================ ===========================================
|
2012-10-19 16:19:17 +00:00
|
|
|
Program Description Required Supported Versions
|
2023-06-30 04:03:08 +00:00
|
|
|
======================== ==================================== ================================ ===========================================
|
2023-06-29 19:45:36 +00:00
|
|
|
:doc:`GEOS <../geos>` Geometry Engine Open Source Yes 3.11, 3.10, 3.9, 3.8
|
2023-01-11 17:30:10 +00:00
|
|
|
`PROJ`_ Cartographic Projections library Yes (PostgreSQL and SQLite only) 9.x, 8.x, 7.x, 6.x, 5.x
|
2023-06-30 04:03:08 +00:00
|
|
|
:doc:`GDAL <../gdal>` Geospatial Data Abstraction Library Yes 3.7, 3.6, 3.5, 3.4, 3.3, 3.2, 3.1, 3.0, 2.4
|
2016-12-31 00:06:30 +00:00
|
|
|
:doc:`GeoIP <../geoip2>` IP-based geolocation library No 2
|
2022-10-12 07:04:32 +00:00
|
|
|
`PostGIS`__ Spatial extensions for PostgreSQL Yes (PostgreSQL only) 3.3, 3.2, 3.1, 3.0, 2.5
|
2021-04-03 14:23:19 +00:00
|
|
|
`SpatiaLite`__ Spatial extensions for SQLite Yes (SQLite only) 5.0, 4.3
|
2023-06-30 04:03:08 +00:00
|
|
|
======================== ==================================== ================================ ===========================================
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2014-03-27 21:30:50 +00:00
|
|
|
Note that older or more recent versions of these libraries *may* also work
|
|
|
|
totally fine with GeoDjango. Your mileage may vary.
|
|
|
|
|
2013-07-06 15:18:53 +00:00
|
|
|
..
|
|
|
|
Libs release dates:
|
2020-05-12 07:05:13 +00:00
|
|
|
GEOS 3.8.0 2019-10-10
|
2021-04-03 12:47:27 +00:00
|
|
|
GEOS 3.9.0 2020-12-14
|
2021-10-21 18:23:58 +00:00
|
|
|
GEOS 3.10.0 2021-10-20
|
2022-07-18 18:03:26 +00:00
|
|
|
GEOS 3.11.0 2022-07-01
|
2019-02-09 13:38:49 +00:00
|
|
|
GDAL 2.4.0 2018-12
|
2020-05-08 09:28:52 +00:00
|
|
|
GDAL 3.0.0 2019-05
|
2020-05-12 09:25:19 +00:00
|
|
|
GDAL 3.1.0 2020-05-07
|
2021-04-03 12:47:27 +00:00
|
|
|
GDAL 3.2.0 2020-11-02
|
2021-07-16 07:36:53 +00:00
|
|
|
GDAL 3.3.0 2021-05-03
|
2022-03-16 08:07:01 +00:00
|
|
|
GDAL 3.4.0 2021-11-04
|
2022-06-16 07:44:19 +00:00
|
|
|
GDAL 3.5.0 2022-05-13
|
2022-12-29 10:35:41 +00:00
|
|
|
GDAL 3.6.0 2022-11-03
|
2023-06-30 04:03:08 +00:00
|
|
|
GDAL 3.7.0 2023-05-10
|
2018-09-26 17:36:10 +00:00
|
|
|
PostGIS 2.5.0 2018-09-23
|
2020-01-19 19:01:08 +00:00
|
|
|
PostGIS 3.0.0 2019-10-20
|
2021-07-19 04:49:41 +00:00
|
|
|
PostGIS 3.1.0 2020-12-18
|
2022-01-10 17:47:32 +00:00
|
|
|
PostGIS 3.2.0 2021-12-18
|
2022-10-12 07:04:32 +00:00
|
|
|
PostGIS 3.3.0 2022-08-27
|
2022-03-25 08:10:32 +00:00
|
|
|
PROJ 9.0.0 2022-03-01
|
|
|
|
PROJ 8.0.0 2021-03-01
|
|
|
|
PROJ 8.0.0 2021-03-01
|
|
|
|
PROJ 7.0.0 2020-02-25
|
|
|
|
PROJ 6.0.0 2019-02-26
|
|
|
|
PROJ 5.0.0 2018-03-01
|
2016-08-09 16:46:14 +00:00
|
|
|
SpatiaLite 4.3.0 2015-09-07
|
2021-04-03 14:23:19 +00:00
|
|
|
SpatiaLite 5.0.0 2020-08-23
|
2013-07-06 15:18:53 +00:00
|
|
|
|
2012-10-19 16:19:17 +00:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
The GeoDjango interfaces to GEOS, GDAL, and GeoIP may be used
|
|
|
|
independently of Django. In other words, no database or settings file
|
2019-06-17 14:54:55 +00:00
|
|
|
required -- import them as normal from :mod:`django.contrib.gis`.
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2020-05-10 20:30:03 +00:00
|
|
|
.. _PROJ: https://proj.org/
|
2017-03-16 18:01:45 +00:00
|
|
|
__ https://postgis.net/
|
|
|
|
__ https://www.gaia-gis.it/gaia-sins/
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
On Debian/Ubuntu, you are advised to install the following packages which will
|
|
|
|
install, directly or by dependency, the required geospatial libraries:
|
|
|
|
|
2015-02-19 03:19:21 +00:00
|
|
|
.. code-block:: console
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
$ sudo apt-get install binutils libproj-dev gdal-bin
|
|
|
|
|
2017-04-23 20:06:12 +00:00
|
|
|
Please also consult platform-specific instructions if you are on :ref:`macos`
|
2012-10-19 16:19:17 +00:00
|
|
|
or :ref:`windows`.
|
|
|
|
|
|
|
|
.. _build_from_source:
|
|
|
|
|
|
|
|
Building from source
|
|
|
|
====================
|
|
|
|
|
|
|
|
When installing from source on UNIX and GNU/Linux systems, please follow
|
|
|
|
the installation instructions carefully, and install the libraries in the
|
|
|
|
given order. If using MySQL or Oracle as the spatial database, only GEOS
|
|
|
|
is required.
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
2016-02-19 07:31:25 +00:00
|
|
|
On Linux platforms, it may be necessary to run the ``ldconfig`` command
|
|
|
|
after installing each library. For example:
|
2023-02-09 15:48:46 +00:00
|
|
|
|
2016-02-19 07:31:25 +00:00
|
|
|
.. code-block:: shell
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2016-02-19 07:31:25 +00:00
|
|
|
$ sudo make install
|
|
|
|
$ sudo ldconfig
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
2017-04-23 20:06:12 +00:00
|
|
|
macOS users must install `Xcode`_ in order to compile software from source.
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2017-04-23 20:06:12 +00:00
|
|
|
.. _Xcode: https://developer.apple.com/xcode/
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. _geosbuild:
|
|
|
|
|
|
|
|
GEOS
|
|
|
|
----
|
|
|
|
|
|
|
|
GEOS is a C++ library for performing geometric operations, and is the default
|
|
|
|
internal geometry representation used by GeoDjango (it's behind the "lazy"
|
|
|
|
geometries). Specifically, the C API library is called (e.g., ``libgeos_c.so``)
|
|
|
|
directly from Python using ctypes.
|
|
|
|
|
2018-06-12 19:22:05 +00:00
|
|
|
First, download GEOS from the GEOS website and untar the source archive:
|
2023-02-09 15:48:46 +00:00
|
|
|
|
2018-06-12 19:22:05 +00:00
|
|
|
.. code-block:: shell
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2018-11-10 22:40:50 +00:00
|
|
|
$ wget https://download.osgeo.org/geos/geos-X.Y.Z.tar.bz2
|
2018-06-12 19:22:05 +00:00
|
|
|
$ tar xjf geos-X.Y.Z.tar.bz2
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2022-03-25 10:48:43 +00:00
|
|
|
Then step into the GEOS directory, create a ``build`` folder, and step into
|
|
|
|
it:
|
2023-02-09 15:48:46 +00:00
|
|
|
|
2022-03-25 10:48:43 +00:00
|
|
|
.. code-block:: shell
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2018-06-12 19:22:05 +00:00
|
|
|
$ cd geos-X.Y.Z
|
2022-03-25 10:48:43 +00:00
|
|
|
$ mkdir build
|
|
|
|
$ cd build
|
|
|
|
|
|
|
|
Then build and install the package:
|
2023-02-09 15:48:46 +00:00
|
|
|
|
2022-03-25 10:48:43 +00:00
|
|
|
.. code-block:: shell
|
|
|
|
|
|
|
|
$ cmake -DCMAKE_BUILD_TYPE=Release ..
|
|
|
|
$ cmake --build .
|
|
|
|
$ sudo cmake --build . --target install
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
Troubleshooting
|
2016-01-03 10:56:22 +00:00
|
|
|
~~~~~~~~~~~~~~~
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
Can't find GEOS library
|
2016-01-03 10:56:22 +00:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
When GeoDjango can't find GEOS, this error is raised:
|
|
|
|
|
|
|
|
.. code-block:: text
|
|
|
|
|
|
|
|
ImportError: Could not find the GEOS library (tried "geos_c"). Try setting GEOS_LIBRARY_PATH in your settings.
|
|
|
|
|
|
|
|
The most common solution is to properly configure your :ref:`libsettings` *or* set
|
|
|
|
:ref:`geoslibrarypath` in your settings.
|
|
|
|
|
|
|
|
If using a binary package of GEOS (e.g., on Ubuntu), you may need to :ref:`binutils`.
|
|
|
|
|
|
|
|
.. _geoslibrarypath:
|
|
|
|
|
|
|
|
``GEOS_LIBRARY_PATH``
|
2016-01-03 10:56:22 +00:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
If your GEOS library is in a non-standard location, or you don't want to
|
|
|
|
modify the system's library path then the :setting:`GEOS_LIBRARY_PATH`
|
|
|
|
setting may be added to your Django settings file with the full path to the
|
2014-08-18 14:30:44 +00:00
|
|
|
GEOS C library. For example:
|
2023-02-09 15:48:46 +00:00
|
|
|
|
2014-08-18 14:30:44 +00:00
|
|
|
.. code-block:: shell
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
GEOS_LIBRARY_PATH = '/home/bob/local/lib/libgeos_c.so'
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
The setting must be the *full* path to the **C** shared library; in
|
|
|
|
other words you want to use ``libgeos_c.so``, not ``libgeos.so``.
|
|
|
|
|
|
|
|
See also :ref:`My logs are filled with GEOS-related errors <geos-exceptions-in-logfile>`.
|
|
|
|
|
|
|
|
.. _proj4:
|
|
|
|
|
2020-05-10 20:30:03 +00:00
|
|
|
PROJ
|
|
|
|
----
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2020-05-10 20:30:03 +00:00
|
|
|
`PROJ`_ is a library for converting geospatial data to different coordinate
|
2012-10-19 16:19:17 +00:00
|
|
|
reference systems.
|
|
|
|
|
2021-03-16 19:22:35 +00:00
|
|
|
First, download the PROJ source code:
|
2023-02-09 15:48:46 +00:00
|
|
|
|
2021-03-16 19:22:35 +00:00
|
|
|
.. code-block:: shell
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2018-11-10 22:40:50 +00:00
|
|
|
$ wget https://download.osgeo.org/proj/proj-X.Y.Z.tar.gz
|
2021-03-16 19:22:35 +00:00
|
|
|
|
|
|
|
... and datum shifting files (download ``proj-datumgrid-X.Y.tar.gz`` for
|
|
|
|
PROJ < 7.x) [#]_:
|
2023-02-09 15:48:46 +00:00
|
|
|
|
2021-03-16 19:22:35 +00:00
|
|
|
.. code-block:: shell
|
|
|
|
|
|
|
|
$ wget https://download.osgeo.org/proj/proj-data-X.Y.tar.gz
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
Next, untar the source code archive, and extract the datum shifting files in the
|
2021-03-15 07:20:36 +00:00
|
|
|
``data`` subdirectory (use ``nad`` subdirectory for PROJ < 6.x). This must be
|
|
|
|
done *prior* to configuration:
|
2023-02-09 15:48:46 +00:00
|
|
|
|
2021-03-15 07:20:36 +00:00
|
|
|
.. code-block:: shell
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2018-06-12 19:22:05 +00:00
|
|
|
$ tar xzf proj-X.Y.Z.tar.gz
|
2021-03-15 07:20:36 +00:00
|
|
|
$ cd proj-X.Y.Z/data
|
2021-03-16 19:22:35 +00:00
|
|
|
$ tar xzf ../../proj-data-X.Y.tar.gz
|
2022-03-25 08:10:32 +00:00
|
|
|
$ cd ../..
|
|
|
|
|
|
|
|
For PROJ 9.x and greater, releases only support builds using ``CMake`` (see
|
|
|
|
`PROJ RFC-7`_).
|
|
|
|
|
|
|
|
To build with ``CMake`` ensure your system meets the `build requirements`_.
|
|
|
|
Then create a ``build`` folder in the PROJ directory, and step into it:
|
2023-02-09 15:48:46 +00:00
|
|
|
|
2022-03-25 08:10:32 +00:00
|
|
|
.. code-block:: shell
|
|
|
|
|
|
|
|
$ cd proj-X.Y.Z
|
|
|
|
$ mkdir build
|
|
|
|
$ cd build
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2020-05-10 20:30:03 +00:00
|
|
|
Finally, configure, make and install PROJ:
|
2023-02-09 15:48:46 +00:00
|
|
|
|
2020-05-10 20:30:03 +00:00
|
|
|
.. code-block:: shell
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2022-03-25 08:10:32 +00:00
|
|
|
$ cmake ..
|
|
|
|
$ cmake --build .
|
|
|
|
$ sudo cmake --build . --target install
|
|
|
|
|
|
|
|
.. _PROJ RFC-7: https://proj.org/community/rfc/rfc-7.html#rfc7
|
|
|
|
.. _build requirements: https://proj.org/install.html#build-requirements
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. _gdalbuild:
|
|
|
|
|
|
|
|
GDAL
|
|
|
|
----
|
|
|
|
|
|
|
|
`GDAL`__ is an excellent open source geospatial library that has support for
|
|
|
|
reading most vector and raster spatial data formats. Currently, GeoDjango only
|
2014-11-26 17:46:06 +00:00
|
|
|
supports :doc:`GDAL's vector data <../gdal>` capabilities [#]_.
|
2012-10-19 16:19:17 +00:00
|
|
|
:ref:`geosbuild` and :ref:`proj4` should be installed prior to building GDAL.
|
|
|
|
|
|
|
|
First download the latest GDAL release version and untar the archive:
|
2023-02-09 15:48:46 +00:00
|
|
|
|
2012-10-19 16:19:17 +00:00
|
|
|
.. code-block:: shell
|
|
|
|
|
2018-11-10 22:40:50 +00:00
|
|
|
$ wget https://download.osgeo.org/gdal/X.Y.Z/gdal-X.Y.Z.tar.gz
|
2018-06-12 19:22:05 +00:00
|
|
|
$ tar xzf gdal-X.Y.Z.tar.gz
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2022-12-29 10:35:41 +00:00
|
|
|
For GDAL 3.6.x and greater, releases only support builds using ``CMake``. To
|
|
|
|
build with ``CMake`` create a ``build`` folder in the GDAL directory, and step
|
|
|
|
into it:
|
2023-02-09 15:48:46 +00:00
|
|
|
|
2022-12-29 10:35:41 +00:00
|
|
|
.. code-block:: shell
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2022-12-29 10:35:41 +00:00
|
|
|
$ cd gdal-X.Y.Z
|
|
|
|
$ mkdir build
|
|
|
|
$ cd build
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2022-12-29 10:35:41 +00:00
|
|
|
Finally, configure, make and install GDAL:
|
2023-02-09 15:48:46 +00:00
|
|
|
|
2022-12-29 10:35:41 +00:00
|
|
|
.. code-block:: shell
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2022-12-29 10:35:41 +00:00
|
|
|
$ cmake ..
|
|
|
|
$ cmake --build .
|
|
|
|
$ sudo cmake --build . --target install
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
If you have any problems, please see the troubleshooting section below for
|
|
|
|
suggestions and solutions.
|
|
|
|
|
2022-01-17 15:00:14 +00:00
|
|
|
__ https://gdal.org/
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. _gdaltrouble:
|
|
|
|
|
|
|
|
Troubleshooting
|
2016-01-03 10:56:22 +00:00
|
|
|
~~~~~~~~~~~~~~~
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
Can't find GDAL library
|
2016-01-03 10:56:22 +00:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^
|
2012-10-19 16:19:17 +00:00
|
|
|
|
2017-05-03 01:27:11 +00:00
|
|
|
When GeoDjango can't find the GDAL library, configure your :ref:`libsettings`
|
|
|
|
*or* set :ref:`gdallibrarypath` in your settings.
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
.. _gdallibrarypath:
|
|
|
|
|
|
|
|
``GDAL_LIBRARY_PATH``
|
2016-01-03 10:56:22 +00:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
If your GDAL library is in a non-standard location, or you don't want to
|
|
|
|
modify the system's library path then the :setting:`GDAL_LIBRARY_PATH`
|
|
|
|
setting may be added to your Django settings file with the full path to
|
2014-08-18 14:30:44 +00:00
|
|
|
the GDAL library. For example:
|
2023-02-09 15:48:46 +00:00
|
|
|
|
2014-08-18 14:30:44 +00:00
|
|
|
.. code-block:: shell
|
2012-10-19 16:19:17 +00:00
|
|
|
|
|
|
|
GDAL_LIBRARY_PATH = '/home/sue/local/lib/libgdal.so'
|
|
|
|
|
|
|
|
.. rubric:: Footnotes
|
|
|
|
.. [#] The datum shifting files are needed for converting data to and from
|
|
|
|
certain projections.
|
2020-05-10 20:30:03 +00:00
|
|
|
For example, the PROJ string for the `Google projection (900913 or 3857)
|
2020-01-29 08:34:37 +00:00
|
|
|
<https://spatialreference.org/ref/sr-org/6864/prj/>`_ requires the
|
2012-10-19 16:19:17 +00:00
|
|
|
``null`` grid file only included in the extra datum shifting files.
|
|
|
|
It is easier to install the shifting files now, then to have debug a
|
|
|
|
problem caused by their absence later.
|
|
|
|
.. [#] Specifically, GeoDjango provides support for the `OGR
|
2019-08-19 09:43:06 +00:00
|
|
|
<https://gdal.org/user/vector_data_model.html>`_ library, a component of
|
|
|
|
GDAL.
|