2
0

geolibs.txt 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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.13, 3.12, 3.11, 3.10, 3.9, 3.8
  10. `PROJ`_ Cartographic Projections library Yes (PostgreSQL and SQLite only) 9.x, 8.x, 7.x, 6.x
  11. :doc:`GDAL <../gdal>` Geospatial Data Abstraction Library Yes 3.10, 3.9, 3.8, 3.7, 3.6, 3.5, 3.4, 3.3, 3.2, 3.1
  12. :doc:`GeoIP <../geoip2>` IP-based geolocation library No 2
  13. `PostGIS`__ Spatial extensions for PostgreSQL Yes (PostgreSQL only) 3.4, 3.3, 3.2, 3.1
  14. `SpatiaLite`__ Spatial extensions for SQLite Yes (SQLite only) 5.1, 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.8.0 2019-10-10
  21. GEOS 3.9.0 2020-12-14
  22. GEOS 3.10.0 2021-10-20
  23. GEOS 3.11.0 2022-07-01
  24. GEOS 3.12.0 2023-06-27
  25. GEOS 3.13.0 2024-09-06
  26. GDAL 3.1.0 2020-05-07
  27. GDAL 3.2.0 2020-11-02
  28. GDAL 3.3.0 2021-05-03
  29. GDAL 3.4.0 2021-11-04
  30. GDAL 3.5.0 2022-05-13
  31. GDAL 3.6.0 2022-11-03
  32. GDAL 3.7.0 2023-05-10
  33. GDAL 3.8.0 2023-11-13
  34. GDAL 3.9.0 2024-05-10
  35. GDAL 3.10.0 2024-11-06
  36. PostGIS 3.1.0 2020-12-18
  37. PostGIS 3.2.0 2021-12-18
  38. PostGIS 3.3.0 2022-08-27
  39. PostGIS 3.4.0 2023-08-15
  40. PROJ 9.0.0 2022-03-01
  41. PROJ 8.0.0 2021-03-01
  42. PROJ 8.0.0 2021-03-01
  43. PROJ 7.0.0 2020-02-25
  44. PROJ 6.0.0 2019-02-26
  45. SpatiaLite 4.3.0 2015-09-07
  46. SpatiaLite 5.0.0 2020-08-23
  47. SpatiaLite 5.1.0 2023-08-04
  48. .. note::
  49. The GeoDjango interfaces to GEOS, GDAL, and GeoIP may be used
  50. independently of Django. In other words, no database or settings file
  51. required -- import them as normal from :mod:`django.contrib.gis`.
  52. .. _PROJ: https://proj.org/
  53. __ https://postgis.net/
  54. __ https://www.gaia-gis.it/gaia-sins/
  55. On Debian/Ubuntu, you are advised to install the following packages which will
  56. install, directly or by dependency, the required geospatial libraries:
  57. .. code-block:: console
  58. $ sudo apt-get install binutils libproj-dev gdal-bin
  59. Please also consult platform-specific instructions if you are on :ref:`macos`
  60. or :ref:`windows`.
  61. .. _build_from_source:
  62. Building from source
  63. ====================
  64. When installing from source on UNIX and GNU/Linux systems, please follow
  65. the installation instructions carefully, and install the libraries in the
  66. given order. If using MySQL or Oracle as the spatial database, only GEOS
  67. is required.
  68. .. note::
  69. On Linux platforms, it may be necessary to run the ``ldconfig`` command
  70. after installing each library. For example:
  71. .. code-block:: shell
  72. $ sudo make install
  73. $ sudo ldconfig
  74. .. note::
  75. macOS users must install `Xcode`_ in order to compile software from source.
  76. .. _Xcode: https://developer.apple.com/xcode/
  77. .. _geosbuild:
  78. GEOS
  79. ----
  80. GEOS is a C++ library for performing geometric operations, and is the default
  81. internal geometry representation used by GeoDjango (it's behind the "lazy"
  82. geometries). Specifically, the C API library is called (e.g., ``libgeos_c.so``)
  83. directly from Python using ctypes.
  84. First, download GEOS from the GEOS website and untar the source archive:
  85. .. code-block:: shell
  86. $ wget https://download.osgeo.org/geos/geos-X.Y.Z.tar.bz2
  87. $ tar xjf geos-X.Y.Z.tar.bz2
  88. Then step into the GEOS directory, create a ``build`` folder, and step into
  89. it:
  90. .. code-block:: shell
  91. $ cd geos-X.Y.Z
  92. $ mkdir build
  93. $ cd build
  94. Then build and install the package:
  95. .. code-block:: shell
  96. $ cmake -DCMAKE_BUILD_TYPE=Release ..
  97. $ cmake --build .
  98. $ sudo cmake --build . --target install
  99. Troubleshooting
  100. ~~~~~~~~~~~~~~~
  101. Can't find GEOS library
  102. ^^^^^^^^^^^^^^^^^^^^^^^
  103. When GeoDjango can't find GEOS, this error is raised:
  104. .. code-block:: text
  105. ImportError: Could not find the GEOS library (tried "geos_c"). Try setting GEOS_LIBRARY_PATH in your settings.
  106. The most common solution is to properly configure your :ref:`libsettings` *or* set
  107. :ref:`geoslibrarypath` in your settings.
  108. If using a binary package of GEOS (e.g., on Ubuntu), you may need to :ref:`binutils`.
  109. .. _geoslibrarypath:
  110. ``GEOS_LIBRARY_PATH``
  111. ^^^^^^^^^^^^^^^^^^^^^
  112. If your GEOS library is in a non-standard location, or you don't want to
  113. modify the system's library path then the :setting:`GEOS_LIBRARY_PATH`
  114. setting may be added to your Django settings file with the full path to the
  115. GEOS C library. For example:
  116. .. code-block:: shell
  117. GEOS_LIBRARY_PATH = '/home/bob/local/lib/libgeos_c.so'
  118. .. note::
  119. The setting must be the *full* path to the **C** shared library; in
  120. other words you want to use ``libgeos_c.so``, not ``libgeos.so``.
  121. See also :ref:`My logs are filled with GEOS-related errors <geos-exceptions-in-logfile>`.
  122. .. _proj4:
  123. PROJ
  124. ----
  125. `PROJ`_ is a library for converting geospatial data to different coordinate
  126. reference systems.
  127. First, download the PROJ source code:
  128. .. code-block:: shell
  129. $ wget https://download.osgeo.org/proj/proj-X.Y.Z.tar.gz
  130. ... and datum shifting files (download ``proj-datumgrid-X.Y.tar.gz`` for
  131. PROJ < 7.x) [#]_:
  132. .. code-block:: shell
  133. $ wget https://download.osgeo.org/proj/proj-data-X.Y.tar.gz
  134. Next, untar the source code archive, and extract the datum shifting files in the
  135. ``data`` subdirectory. This must be done *prior* to configuration:
  136. .. code-block:: shell
  137. $ tar xzf proj-X.Y.Z.tar.gz
  138. $ cd proj-X.Y.Z/data
  139. $ tar xzf ../../proj-data-X.Y.tar.gz
  140. $ cd ../..
  141. For PROJ 9.x and greater, releases only support builds using ``CMake`` (see
  142. `PROJ RFC-7`_).
  143. To build with ``CMake`` ensure your system meets the `build requirements`_.
  144. Then create a ``build`` folder in the PROJ directory, and step into it:
  145. .. code-block:: shell
  146. $ cd proj-X.Y.Z
  147. $ mkdir build
  148. $ cd build
  149. Finally, configure, make and install PROJ:
  150. .. code-block:: shell
  151. $ cmake ..
  152. $ cmake --build .
  153. $ sudo cmake --build . --target install
  154. .. _PROJ RFC-7: https://proj.org/community/rfc/rfc-7.html#rfc7
  155. .. _build requirements: https://proj.org/install.html#build-requirements
  156. .. _gdalbuild:
  157. GDAL
  158. ----
  159. `GDAL`__ is an excellent open source geospatial library that has support for
  160. reading most vector and raster spatial data formats. Currently, GeoDjango only
  161. supports :doc:`GDAL's vector data <../gdal>` capabilities [#]_.
  162. :ref:`geosbuild` and :ref:`proj4` should be installed prior to building GDAL.
  163. First download the latest GDAL release version and untar the archive:
  164. .. code-block:: shell
  165. $ wget https://download.osgeo.org/gdal/X.Y.Z/gdal-X.Y.Z.tar.gz
  166. $ tar xzf gdal-X.Y.Z.tar.gz
  167. For GDAL 3.6.x and greater, releases only support builds using ``CMake``. To
  168. build with ``CMake`` create a ``build`` folder in the GDAL directory, and step
  169. into it:
  170. .. code-block:: shell
  171. $ cd gdal-X.Y.Z
  172. $ mkdir build
  173. $ cd build
  174. Finally, configure, make and install GDAL:
  175. .. code-block:: shell
  176. $ cmake ..
  177. $ cmake --build .
  178. $ sudo cmake --build . --target install
  179. If you have any problems, please see the troubleshooting section below for
  180. suggestions and solutions.
  181. __ https://gdal.org/
  182. .. _gdaltrouble:
  183. Troubleshooting
  184. ~~~~~~~~~~~~~~~
  185. Can't find GDAL library
  186. ^^^^^^^^^^^^^^^^^^^^^^^
  187. When GeoDjango can't find the GDAL library, configure your :ref:`libsettings`
  188. *or* set :ref:`gdallibrarypath` in your settings.
  189. .. _gdallibrarypath:
  190. ``GDAL_LIBRARY_PATH``
  191. ^^^^^^^^^^^^^^^^^^^^^
  192. If your GDAL library is in a non-standard location, or you don't want to
  193. modify the system's library path then the :setting:`GDAL_LIBRARY_PATH`
  194. setting may be added to your Django settings file with the full path to
  195. the GDAL library. For example:
  196. .. code-block:: shell
  197. GDAL_LIBRARY_PATH = '/home/sue/local/lib/libgdal.so'
  198. .. rubric:: Footnotes
  199. .. [#] The datum shifting files are needed for converting data to and from
  200. certain projections.
  201. For example, the PROJ string for the `Google projection (900913 or 3857)
  202. <https://spatialreference.org/ref/epsg/3857/>`_ requires the ``null``
  203. grid file only included in the extra datum shifting files. It is easier
  204. to install the shifting files now, then to have debug a problem caused
  205. by their absence later.
  206. .. [#] Specifically, GeoDjango provides support for the `OGR
  207. <https://gdal.org/user/vector_data_model.html>`_ library, a component of
  208. GDAL.