Installing Geospatial librariesLink to this heading

GeoDjango uses and/or provides interfaces for the following open source geospatial libraries:

Program

Deskripsi

Dibutuhkan

Versi Didukung

GEOS

Geometry Engine Open Source

Ya

3.4, 3.3, 3.2

PROJ.4

Cartographic Projections library

Ya (hanya PostgreSQL dan SQLite )

4.9, 4.8, 4.7, 4.6, 4.5, 4.4

GDAL

Geospatial Data Abstraction Library

Ya (hanya SQLite )

2.0, 1.11, 1.10, 1.9, 1.8, 1.7

GeoIP

IP-based geolocation library

Tidak

1.4

PostGIS

Spatial extensions for PostgreSQL

Ya (hanya PostgreSQL)

2.1, 2.0

SpatiaLite

Spatial extensions for SQLite

Ya (hanya SQLite )

4.3, 4.2, 4.1, 4.0, 3.0, 2.4

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:

Shell
$ sudo apt-get install binutils libproj-dev gdal-bin

Paket pilihan untuk dipertimbangkan:

  • Dukungan libgeoip1: for GeoIP

  • gdal-bin: untuk program baris perintah GDAL seperti ogr2ogr

  • python-gdal for GDAL's own Python bindings -- includes interfaces for raster manipulation

Please also consult platform-specific instructions if you are on Mac OS X or Windows.

Membangun dari sumberLink 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 3.4.2 from the GEOS website and untar the source archive:

Code
$ wget http://download.osgeo.org/geos/geos-3.4.2.tar.bz2
$ tar xjf geos-3.4.2.tar.bz2

Next, change into the directory where GEOS was unpacked, run the configure script, compile, and install:

Code
$ cd geos-3.4.2
$ ./configure
$ make
$ sudo make install
$ cd ..

Menyelesaikan masalahLink to this heading

Tidak dapat menemukan pustaka GEOSLink to this heading

Ketika GeoDjango tidak dapat menemukan GEOS, kesalahan ini akan muncul:

Text
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 Pustaka pengaturan lingkungan or set GEOS_LIBRARY_PATH in your settings.

Jika menggunakan paket biner dari GEOS (sebagai contoh pada Ubuntu), anda mungkin butuh untuk Pasang 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:

Code
GEOS_LIBRARY_PATH = '/home/bob/local/lib/libgeos_c.so'

Lihat juga Catatan saya diisi dengan kesalahan terkait GEOS.

PROJ.4Link to this heading

PROJ.4 is a library for converting geospatial data to different coordinate reference systems.

First, download the PROJ.4 source code and datum shifting files [1]:

Code
$ wget http://download.osgeo.org/proj/proj-4.9.1.tar.gz
$ wget http://download.osgeo.org/proj/proj-datumgrid-1.5.tar.gz

Next, untar the source code archive, and extract the datum shifting files in the nad subdirectory. This must be done prior to configuration:

Code
$ tar xzf proj-4.9.1.tar.gz
$ cd proj-4.9.1/nad
$ tar xzf ../../proj-datumgrid-1.5.tar.gz
$ cd ..

Akhirnya, konfigurasi, buat dan pasang PROJ.4:

Code
$ ./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.4 should be installed prior to building GDAL.

Pertama unduh versi terbitan GDAL terakhir dan keluarkan arsip:

Code
$ wget http://download.osgeo.org/gdal/1.11.2/gdal-1.11.2.tar.gz
$ tar xzf gdal-1.11.2.tar.gz
$ cd gdal-1.11.2

Konfigurasi, buat dan pasang:

Code
$ ./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.

Menyelesaikan masalahLink to this heading

Tidak dapat menemukan pustaka GDALLink to this heading

Ketika GeoDjango tidak dapat menemukan pustaka GDAL, bendera HAS_GDAL akan salah:

Python console
>>> from django.contrib.gis import gdal
>>> gdal.HAS_GDAL
False

The solution is to properly configure your Pustaka pengaturan lingkungan 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:

Code
GDAL_LIBRARY_PATH = '/home/sue/local/lib/libgdal.so'

Catatan kaki