geolibs.txt 8.1 KB

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