Installing Geospatial librariesLink to this heading
GeoDjango uses and/or provides interfaces for the following open source geospatial libraries:
Program |
説明 |
Required |
Supported Versions |
|---|---|---|---|
Geometry Engine Open Source |
はい |
3.10, 3.9, 3.8, 3.7, 3.6 |
|
Cartographic Projections library |
Yes (PostgreSQL and SQLite only) |
8.x, 7.x, 6.x, 5.x, 4.x |
|
Geospatial Data Abstraction Library |
はい |
3.3, 3.2, 3.1, 3.0, 2.4, 2.3, 2.2, 2.1 |
|
IP-based geolocation library |
いいえ |
2 |
|
Spatial extensions for PostgreSQL |
Yes (PostgreSQL only) |
3.1, 3.0, 2.5, 2.4 |
|
Spatial extensions for SQLite |
Yes (SQLite only) |
5.0, 4.3 |
Note that older or more recent versions of these libraries may also work totally fine with GeoDjango. Your mileage may vary.
On Debian/Ubuntu, you are advised to install the following packages which will install, directly or by dependency, the required geospatial libraries:
$ sudo apt-get install binutils libproj-dev gdal-bin
Please also consult platform-specific instructions if you are on macOS or Windows.
Building from sourceLink to this heading
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.
GEOSLink to this heading
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.
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.bz2
Next, change into the directory where GEOS was unpacked, run the configure script, compile, and install:
$ cd geos-X.Y.Z
$ ./configure
$ make
$ sudo make install
$ cd ..
トラブルシューティングLink to this heading
Can't find GEOS libraryLink to this heading
When GeoDjango can't find GEOS, this error is raised:
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 Library environment settings or set GEOS_LIBRARY_PATH in your settings.
If using a binary package of GEOS (e.g., on Ubuntu), you may need to Install binutils.
GEOS_LIBRARY_PATHLink to this heading
If your GEOS library is in a non-standard location, or you don't want to
modify the system's library path then the GEOS_LIBRARY_PATH
setting may be added to your Django settings file with the full path to the
GEOS C library. For example:
GEOS_LIBRARY_PATH = '/home/bob/local/lib/libgeos_c.so'
PROJLink to this heading
PROJ is a library for converting geospatial data to different coordinate reference 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 for
PROJ < 7.x) [1]:
$ wget https://download.osgeo.org/proj/proj-data-X.Y.tar.gz
Next, untar the source code archive, and extract the datum shifting files in the
data subdirectory (use nad subdirectory for PROJ < 6.x). This must be
done 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 ..
Finally, configure, make and install PROJ:
$ ./configure
$ make
$ sudo make install
$ cd ..
GDALLink to this heading
GDAL is an excellent open source geospatial library that has support for reading most vector and raster spatial data formats. Currently, GeoDjango only supports GDAL's vector data capabilities [2]. GEOS and PROJ 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.Z
Configure, make and install:
$ ./configure
$ make # Go get some coffee, this takes a while.
$ sudo make install
$ cd ..
If you have any problems, please see the troubleshooting section below for suggestions and solutions.
トラブルシューティングLink to this heading
Can't find GDAL libraryLink to this heading
When GeoDjango can't find the GDAL library, configure your Library environment settings or set GDAL_LIBRARY_PATH in your settings.
GDAL_LIBRARY_PATHLink to this heading
If your GDAL library is in a non-standard location, or you don't want to
modify the system's library path then the GDAL_LIBRARY_PATH
setting may be added to your Django settings file with the full path to
the GDAL library. For example:
GDAL_LIBRARY_PATH = '/home/sue/local/lib/libgdal.so'
Footnotes