===============================Installing Geospatial libraries===============================GeoDjango uses and/or provides interfaces for the following open sourcegeospatial libraries:======================== ==================================== ================================ ======================================Program Description Required Supported Versions======================== ==================================== ================================ ======================================:doc:`GEOS <../geos>` Geometry Engine Open Source Yes 3.10, 3.9, 3.8, 3.7, 3.6`PROJ`_ Cartographic Projections library Yes (PostgreSQL and SQLite only) 9.x, 8.x, 7.x, 6.x, 5.x, 4.x:doc:`GDAL <../gdal>` Geospatial Data Abstraction Library Yes 3.4, 3.3, 3.2, 3.1, 3.0, 2.4, 2.3, 2.2:doc:`GeoIP <../geoip2>` IP-based geolocation library No 2`PostGIS`__ Spatial extensions for PostgreSQL Yes (PostgreSQL only) 3.2, 3.1, 3.0, 2.5`SpatiaLite`__ Spatial extensions for SQLite Yes (SQLite only) 5.0, 4.3======================== ==================================== ================================ ======================================Note that older or more recent versions of these libraries *may* also worktotally fine with GeoDjango. Your mileage may vary...Libs release dates:GEOS 3.6.0 2016-10-25GEOS 3.7.0 2018-09-10GEOS 3.8.0 2019-10-10GEOS 3.9.0 2020-12-14GEOS 3.10.0 2021-10-20GDAL 2.2.0 2017-05GDAL 2.3.0 2018-05GDAL 2.4.0 2018-12GDAL 3.0.0 2019-05GDAL 3.1.0 2020-05-07GDAL 3.2.0 2020-11-02GDAL 3.3.0 2021-05-03GDAL 3.4.0 2021-11-04PostGIS 2.5.0 2018-09-23PostGIS 3.0.0 2019-10-20PostGIS 3.1.0 2020-12-18PostGIS 3.2.0 2021-12-18PROJ 9.0.0 2022-03-01PROJ 8.0.0 2021-03-01PROJ 8.0.0 2021-03-01PROJ 7.0.0 2020-02-25PROJ 6.0.0 2019-02-26PROJ 5.0.0 2018-03-01PROJ 4.9.0 2014-09-14SpatiaLite 4.3.0 2015-09-07SpatiaLite 5.0.0 2020-08-23.. note::The GeoDjango interfaces to GEOS, GDAL, and GeoIP may be usedindependently of Django. In other words, no database or settings filerequired -- import them as normal from :mod:`django.contrib.gis`... _PROJ: https://proj.org/__ https://postgis.net/__ https://www.gaia-gis.it/gaia-sins/On Debian/Ubuntu, you are advised to install the following packages which willinstall, directly or by dependency, the required geospatial libraries:.. code-block:: console$ sudo apt-get install binutils libproj-dev gdal-binPlease also consult platform-specific instructions if you are on :ref:`macos`or :ref:`windows`... _build_from_source:Building from source====================When installing from source on UNIX and GNU/Linux systems, please followthe installation instructions carefully, and install the libraries in thegiven order. If using MySQL or Oracle as the spatial database, only GEOSis required... note::On Linux platforms, it may be necessary to run the ``ldconfig`` commandafter installing each library. For example::$ sudo make install$ sudo ldconfig.. note::macOS users must install `Xcode`_ in order to compile software from source... _Xcode: https://developer.apple.com/xcode/.. _geosbuild:GEOS----GEOS is a C++ library for performing geometric operations, and is the defaultinternal 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.First, download GEOS from the GEOS website and untar the source archive::$ wget https://download.osgeo.org/geos/geos-X.Y.Z.tar.bz2$ tar xjf geos-X.Y.Z.tar.bz2Then step into the GEOS directory, create a ``build`` folder, and step intoit::$ cd geos-X.Y.Z$ mkdir build$ cd buildThen build and install the package::$ cmake -DCMAKE_BUILD_TYPE=Release ..$ cmake --build .$ sudo cmake --build . --target installTroubleshooting~~~~~~~~~~~~~~~Can't find GEOS library^^^^^^^^^^^^^^^^^^^^^^^When GeoDjango can't find GEOS, this error is raised:.. code-block:: textImportError: 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``^^^^^^^^^^^^^^^^^^^^^If your GEOS library is in a non-standard location, or you don't want tomodify 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 theGEOS C library. For example::GEOS_LIBRARY_PATH = '/home/bob/local/lib/libgeos_c.so'.. note::The setting must be the *full* path to the **C** shared library; inother 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:PROJ----`PROJ`_ is a library for converting geospatial data to different coordinatereference systems.First, download the PROJ source code::$ wget https://download.osgeo.org/proj/proj-X.Y.Z.tar.gz... and datum shifting files (download ``proj-datumgrid-X.Y.tar.gz`` forPROJ < 7.x) [#]_::$ wget https://download.osgeo.org/proj/proj-data-X.Y.tar.gzNext, untar the source code archive, and extract the datum shifting files in the``data`` subdirectory (use ``nad`` subdirectory for PROJ < 6.x). This must bedone *prior* to configuration::$ tar xzf proj-X.Y.Z.tar.gz$ cd proj-X.Y.Z/data$ tar xzf ../../proj-data-X.Y.tar.gz$ 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::$ cd proj-X.Y.Z$ mkdir build$ cd buildFinally, configure, make and install PROJ::$ 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.. _gdalbuild:GDAL----`GDAL`__ is an excellent open source geospatial library that has support forreading most vector and raster spatial data formats. Currently, GeoDjango onlysupports :doc:`GDAL's vector data <../gdal>` capabilities [#]_.:ref:`geosbuild` and :ref:`proj4` should be installed prior to building GDAL.First download the latest GDAL release version and untar the archive::$ wget https://download.osgeo.org/gdal/X.Y.Z/gdal-X.Y.Z.tar.gz$ tar xzf gdal-X.Y.Z.tar.gz$ cd gdal-X.Y.ZConfigure, make and install::$ ./configure$ make # Go get some coffee, this takes a while.$ sudo make install$ cd .... note::Because GeoDjango has its own Python interface, the preceding instructionsdo not build GDAL's own Python bindings. The bindings may be built byadding the ``--with-python`` flag when running ``configure``. See`GDAL/OGR In Python`__ for more information on GDAL's bindings.If you have any problems, please see the troubleshooting section below forsuggestions and solutions.__ https://gdal.org/__ https://gdal.org/api/python.html.. _gdaltrouble:Troubleshooting~~~~~~~~~~~~~~~Can't find GDAL library^^^^^^^^^^^^^^^^^^^^^^^When GeoDjango can't find the GDAL library, configure your :ref:`libsettings`*or* set :ref:`gdallibrarypath` in your settings... _gdallibrarypath:``GDAL_LIBRARY_PATH``^^^^^^^^^^^^^^^^^^^^^If your GDAL library is in a non-standard location, or you don't want tomodify the system's library path then the :setting:`GDAL_LIBRARY_PATH`setting may be added to your Django settings file with the full path tothe GDAL library. For example::GDAL_LIBRARY_PATH = '/home/sue/local/lib/libgdal.so'.. rubric:: Footnotes.. [#] The datum shifting files are needed for converting data to and fromcertain projections.For example, the PROJ string for the `Google projection (900913 or 3857)<https://spatialreference.org/ref/sr-org/6864/prj/>`_ requires the``null`` grid file only included in the extra datum shifting files.It is easier to install the shifting files now, then to have debug aproblem caused by their absence later... [#] Specifically, GeoDjango provides support for the `OGR<https://gdal.org/user/vector_data_model.html>`_ library, a component ofGDAL.