geolibs.txt 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. ===============================
  2. Installing Geospatial libraries
  3. ===============================
  4. GeoDjango uses and/or provides interfaces for the following open source
  5. geospatial libraries:
  6. ======================== ==================================== ================================ ======================================
  7. Program Description Required Supported Versions
  8. ======================== ==================================== ================================ ======================================
  9. :doc:`GEOS <../geos>` Geometry Engine Open Source Yes 3.10, 3.9, 3.8, 3.7, 3.6
  10. `PROJ`_ Cartographic Projections library Yes (PostgreSQL and SQLite only) 8.x, 7.x, 6.x, 5.x, 4.x
  11. :doc:`GDAL <../gdal>` Geospatial Data Abstraction Library Yes 3.3, 3.2, 3.1, 3.0, 2.4, 2.3, 2.2, 2.1
  12. :doc:`GeoIP <../geoip2>` IP-based geolocation library No 2
  13. `PostGIS`__ Spatial extensions for PostgreSQL Yes (PostgreSQL only) 3.2, 3.1, 3.0, 2.5, 2.4
  14. `SpatiaLite`__ Spatial extensions for SQLite Yes (SQLite only) 5.0, 4.3
  15. ======================== ==================================== ================================ ======================================
  16. Note that older or more recent versions of these libraries *may* also work
  17. totally fine with GeoDjango. Your mileage may vary.
  18. ..
  19. Libs release dates:
  20. GEOS 3.6.0 2016-10-25
  21. GEOS 3.7.0 2018-09-10
  22. GEOS 3.8.0 2019-10-10
  23. GEOS 3.9.0 2020-12-14
  24. GEOS 3.10.0 2021-10-20
  25. GDAL 2.1.0 2016-04
  26. GDAL 2.2.0 2017-05
  27. GDAL 2.3.0 2018-05
  28. GDAL 2.4.0 2018-12
  29. GDAL 3.0.0 2019-05
  30. GDAL 3.1.0 2020-05-07
  31. GDAL 3.2.0 2020-11-02
  32. GDAL 3.3.0 2021-05-03
  33. PostGIS 2.4.0 2017-09-30
  34. PostGIS 2.5.0 2018-09-23
  35. PostGIS 3.0.0 2019-10-20
  36. PostGIS 3.1.0 2020-12-18
  37. PostGIS 3.2.0 2021-12-18
  38. SpatiaLite 4.3.0 2015-09-07
  39. SpatiaLite 5.0.0 2020-08-23
  40. .. note::
  41. The GeoDjango interfaces to GEOS, GDAL, and GeoIP may be used
  42. independently of Django. In other words, no database or settings file
  43. required -- import them as normal from :mod:`django.contrib.gis`.
  44. .. _PROJ: https://proj.org/
  45. __ https://postgis.net/
  46. __ https://www.gaia-gis.it/gaia-sins/
  47. On Debian/Ubuntu, you are advised to install the following packages which will
  48. install, directly or by dependency, the required geospatial libraries:
  49. .. code-block:: console
  50. $ sudo apt-get install binutils libproj-dev gdal-bin
  51. Please also consult platform-specific instructions if you are on :ref:`macos`
  52. or :ref:`windows`.
  53. .. _build_from_source:
  54. Building from source
  55. ====================
  56. When installing from source on UNIX and GNU/Linux systems, please follow
  57. the installation instructions carefully, and install the libraries in the
  58. given order. If using MySQL or Oracle as the spatial database, only GEOS
  59. is required.
  60. .. note::
  61. On Linux platforms, it may be necessary to run the ``ldconfig`` command
  62. after installing each library. For example::
  63. $ sudo make install
  64. $ sudo ldconfig
  65. .. note::
  66. macOS users must install `Xcode`_ in order to compile software from source.
  67. .. _Xcode: https://developer.apple.com/xcode/
  68. .. _geosbuild:
  69. GEOS
  70. ----
  71. GEOS is a C++ library for performing geometric operations, and is the default
  72. internal geometry representation used by GeoDjango (it's behind the "lazy"
  73. geometries). Specifically, the C API library is called (e.g., ``libgeos_c.so``)
  74. directly from Python using ctypes.
  75. First, download GEOS from the GEOS website and untar the source archive::
  76. $ wget https://download.osgeo.org/geos/geos-X.Y.Z.tar.bz2
  77. $ tar xjf geos-X.Y.Z.tar.bz2
  78. Next, change into the directory where GEOS was unpacked, run the configure
  79. script, compile, and install::
  80. $ cd geos-X.Y.Z
  81. $ ./configure
  82. $ make
  83. $ sudo make install
  84. $ cd ..
  85. Troubleshooting
  86. ~~~~~~~~~~~~~~~
  87. Can't find GEOS library
  88. ^^^^^^^^^^^^^^^^^^^^^^^
  89. When GeoDjango can't find GEOS, this error is raised:
  90. .. code-block:: text
  91. ImportError: Could not find the GEOS library (tried "geos_c"). Try setting GEOS_LIBRARY_PATH in your settings.
  92. The most common solution is to properly configure your :ref:`libsettings` *or* set
  93. :ref:`geoslibrarypath` in your settings.
  94. If using a binary package of GEOS (e.g., on Ubuntu), you may need to :ref:`binutils`.
  95. .. _geoslibrarypath:
  96. ``GEOS_LIBRARY_PATH``
  97. ^^^^^^^^^^^^^^^^^^^^^
  98. If your GEOS library is in a non-standard location, or you don't want to
  99. modify the system's library path then the :setting:`GEOS_LIBRARY_PATH`
  100. setting may be added to your Django settings file with the full path to the
  101. GEOS C library. For example::
  102. GEOS_LIBRARY_PATH = '/home/bob/local/lib/libgeos_c.so'
  103. .. note::
  104. The setting must be the *full* path to the **C** shared library; in
  105. other words you want to use ``libgeos_c.so``, not ``libgeos.so``.
  106. See also :ref:`My logs are filled with GEOS-related errors <geos-exceptions-in-logfile>`.
  107. .. _proj4:
  108. PROJ
  109. ----
  110. `PROJ`_ is a library for converting geospatial data to different coordinate
  111. reference systems.
  112. First, download the PROJ source code::
  113. $ wget https://download.osgeo.org/proj/proj-X.Y.Z.tar.gz
  114. ... and datum shifting files (download ``proj-datumgrid-X.Y.tar.gz`` for
  115. PROJ < 7.x) [#]_::
  116. $ wget https://download.osgeo.org/proj/proj-data-X.Y.tar.gz
  117. Next, untar the source code archive, and extract the datum shifting files in the
  118. ``data`` subdirectory (use ``nad`` subdirectory for PROJ < 6.x). This must be
  119. done *prior* to configuration::
  120. $ tar xzf proj-X.Y.Z.tar.gz
  121. $ cd proj-X.Y.Z/data
  122. $ tar xzf ../../proj-data-X.Y.tar.gz
  123. $ cd ..
  124. Finally, configure, make and install PROJ::
  125. $ ./configure
  126. $ make
  127. $ sudo make install
  128. $ cd ..
  129. .. _gdalbuild:
  130. GDAL
  131. ----
  132. `GDAL`__ is an excellent open source geospatial library that has support for
  133. reading most vector and raster spatial data formats. Currently, GeoDjango only
  134. supports :doc:`GDAL's vector data <../gdal>` capabilities [#]_.
  135. :ref:`geosbuild` and :ref:`proj4` should be installed prior to building GDAL.
  136. First download the latest GDAL release version and untar the archive::
  137. $ wget https://download.osgeo.org/gdal/X.Y.Z/gdal-X.Y.Z.tar.gz
  138. $ tar xzf gdal-X.Y.Z.tar.gz
  139. $ cd gdal-X.Y.Z
  140. Configure, make and install::
  141. $ ./configure
  142. $ make # Go get some coffee, this takes a while.
  143. $ sudo make install
  144. $ cd ..
  145. .. note::
  146. Because GeoDjango has its own Python interface, the preceding instructions
  147. do not build GDAL's own Python bindings. The bindings may be built by
  148. adding the ``--with-python`` flag when running ``configure``. See
  149. `GDAL/OGR In Python`__ for more information on GDAL's bindings.
  150. If you have any problems, please see the troubleshooting section below for
  151. suggestions and solutions.
  152. __ https://gdal.org/
  153. __ https://gdal.org/api/python.html
  154. .. _gdaltrouble:
  155. Troubleshooting
  156. ~~~~~~~~~~~~~~~
  157. Can't find GDAL library
  158. ^^^^^^^^^^^^^^^^^^^^^^^
  159. When GeoDjango can't find the GDAL library, configure your :ref:`libsettings`
  160. *or* set :ref:`gdallibrarypath` in your settings.
  161. .. _gdallibrarypath:
  162. ``GDAL_LIBRARY_PATH``
  163. ^^^^^^^^^^^^^^^^^^^^^
  164. If your GDAL library is in a non-standard location, or you don't want to
  165. modify the system's library path then the :setting:`GDAL_LIBRARY_PATH`
  166. setting may be added to your Django settings file with the full path to
  167. the GDAL library. For example::
  168. GDAL_LIBRARY_PATH = '/home/sue/local/lib/libgdal.so'
  169. .. rubric:: Footnotes
  170. .. [#] The datum shifting files are needed for converting data to and from
  171. certain projections.
  172. For example, the PROJ string for the `Google projection (900913 or 3857)
  173. <https://spatialreference.org/ref/sr-org/6864/prj/>`_ requires the
  174. ``null`` grid file only included in the extra datum shifting files.
  175. It is easier to install the shifting files now, then to have debug a
  176. problem caused by their absence later.
  177. .. [#] Specifically, GeoDjango provides support for the `OGR
  178. <https://gdal.org/user/vector_data_model.html>`_ library, a component of
  179. GDAL.