Pemasangan GeoDjangoLink to this heading
IkhtisarLink to this heading
Secara umum, pemasangan GeoDjango membutuhkan:
Rincian untuk setiap dari persyaratan dan petunjuk pemasangan disediakan di bagian dibawah. Sebagai tambahan, petunjuk khusus-serambi tersedia untuk:
PersyaratanLink to this heading
Python dan DjangoLink to this heading
Karena GeoDjango disertakan dengan Django, harap mengacu pada installation instructions Django untuk rincian bagaimana memasang.
Basisdata spasialLink to this heading
PostgreSQL (with PostGIS), MySQL, Oracle, and SQLite (with SpatiaLite) are the spatial databases currently supported.
The geospatial libraries required for a GeoDjango installation depends on the spatial database used. The following lists the library requirements, supported versions, and any notes for each of the supported database backends:
Basisdata |
Persyaratan Pustaka |
Versi Didukung |
Catatan |
|---|---|---|---|
PostgreSQL |
GEOS, GDAL, PROJ, PostGIS |
14+ |
Membutuhkan PostGIS. |
MySQL |
GEOS, GDAL |
8.0.11+ |
|
Oracle |
GEOS, GDAL |
19+ |
XE tidak didukung. |
SQLite |
GEOS, GDAL, PROJ, SpatiaLite |
3.31.0+ |
Membutuhkan SpatiaLite 4.3+ |
Lihat juga this comparison matrix pada Wiki OSGeo untuk PostgreSQL/PostGIS/GEOS/GDAL kemungkinan perpaduan.
PemasanganLink to this heading
Pustaka geospasialLink to this heading
Pemasangan basisdataLink to this heading
Konfigurasi DATABASESLink to this heading
Setel pengaturan ENGINE menjadi satu dari the spatial backends.
Tambah django.contrib.gis ke INSTALLED_APPSLink to this heading
Seperti aplikasi bantuan Django lain, anda akan hanya butuh menambahkan django.contrib.gis ke INSTALLED_APPS dalam pengaturan anda. Ini sehingga cetakan gis dapat ditempatkan -- jika belum selesai, kemudian fitur-fitur seperti admin georgafis atau peta situs KML tidak akan berfungsi dengan baik.
Menyelesaikan masalahLink to this heading
Jika anda tidak dapat menemukan pemecahan padamasalah anda disini lalu ikut serta di komunitas! Anda dapat:
Tanya pertanyaan anda di forum GeoDjango.
File a ticket on the Django trac if you think there's a bug. Make sure to provide a complete description of the problem, versions used, and specify the component as "GIS".
Pustaka pengaturan lingkunganLink to this heading
Sejauh ini, masalah paling umum ketika memasang GeoDjango adalah bahwa pustaka-pustaka berbagi eksternal (misalnya, untuk GEOS dan GDAL) tidak dapat ditempatkan. [1] Khususnya, penyebab masalah ini adalah bahwa sistem operasi tidak waspada dari direktori dimana pustaka-pustaka dibangun dari sumber yang dipasang.
Secara umum, jalur pustaka mungkin disetel pada dasar per-pengguna dengan mengatur varibel lingkungan, atau dengan mengkonfigurasi jalur pustaka untuk sistem kesulurhan.
Variabel lingkungan LD_LIBRARY_PATHLink to this heading
A user may set this environment variable to customize the library paths
they want to use. The typical library directory for software
built from source is /usr/local/lib. Thus, /usr/local/lib needs
to be included in the LD_LIBRARY_PATH variable. For example, the user
could place the following in their bash profile:
export LD_LIBRARY_PATH=/usr/local/lib
Menyetel jalur pustakan sistemLink to this heading
On GNU/Linux systems, there is typically a file in /etc/ld.so.conf, which
may include additional paths from files in another directory, such as
/etc/ld.so.conf.d. As the root user, add the custom library path (like
/usr/local/lib) on a new line in ld.so.conf. This is one example of
how to do so:
$ sudo echo /usr/local/lib >> /etc/ld.so.conf
$ sudo ldconfig
For OpenSolaris users, the system library path may be modified using the
crle utility. Run crle with no options to see the current configuration
and use crle -l to set with the new library path. Be very careful when
modifying the system library path:
# crle -l $OLD_PATH:/usr/local/lib
Pasang binutilsLink to this heading
GeoDjango uses the find_library function (from the ctypes.util Python
module) to discover libraries. The find_library routine uses a program
called objdump (part of the binutils package) to verify a shared
library on GNU/Linux systems. Thus, if binutils is not installed on your
Linux system then Python's ctypes may not be able to find your library even if
your library path is set correctly and geospatial libraries were built
perfectly.
The binutils package may be installed on Debian and Ubuntu systems using
the following command:
$ sudo apt-get install binutils
Demikian pula, pada sistem Red Hat dan CentOS:
$ sudo yum install binutils
Petunjuk khusus-serambiLink to this heading
macOSLink to this heading
Karena beragam dari sistem pemaketan tersedia untuk macOS, pengguna mempunyai beberapa pilihan berbeda untuk memasang GeoDjango. Pilihan ini adalah:
Postgres.app (paling mudah dan dianjurkan)
Bagian ini juga menyertakan petunjuk untuk pemasangan sebuah versi tertingkatkan dari Python dari paket-paket disediakan oleh Python Software Foundation, bagaimanapun, ini tidak diwajibkan.
PythonLink to this heading
Although macOS comes with Python installed, users can use framework installers provided by the Python Software Foundation. An advantage to using the installer is that macOS's Python will remain "pristine" for internal operating system use.
Postgres.appLink to this heading
Postgres.app is a standalone PostgreSQL server
that includes the PostGIS extension. You will also need to install gdal
with Homebrew.
Setelah memasang Postgres.app, tambah berikut ke .bash_profile anda sehingga anda dapat menjalankan progam paket dari baris-perintah. Ganti X.Y dengan versi PostgreSQL di Postgres.app anda pasang:
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/X.Y/bin
Anda dapat memeriksa jalur disetel dengan benar dengan mengetik which psql pada terminal prompt.
HomebrewLink to this heading
Homebrew menyediakan "recipes" untuk membangun biner dan paket dari sumber. itu menyediakan resep-resep untuk prasyarat GeoDjango pada komputer Macintosh menjalankan macOS. Karena Homebrew masih membangun perangkat lunak dari sumber, Xcode diwajibkan.
Ringkasan:
$ brew install postgresql
$ brew install postgis
$ brew install gdal
FinkLink to this heading
Kurt Schwehr telah cukup ramah membuat paket-paket GeoDjango untuk pengguna dari sistem paket Fink. Different packages are available (dimulai dengan django-gis), bergantung pada versi mana dari Python anda ingin gunakan.
MacPortsLink to this heading
MacPorts may be used to install GeoDjango prerequisites on computers running macOS. Because MacPorts still builds the software from source, Xcode is required.
Ringkasan:
$ sudo port install postgresql14-server
$ sudo port install geos
$ sudo port install proj6
$ sudo port install postgis3
$ sudo port install gdal
WindowsLink to this heading
Proceed through the following sections sequentially in order to install GeoDjango on Windows. In this tutorial we will install 64 bit versions of each application.
PythonLink to this heading
Install a 64 bit version of Python. See Install Python for further information.
PostgreSQLLink to this heading
Download the latest PostgreSQL 15.x installer from the EnterpriseDB website. After downloading, run the installer, follow the on-screen directions, and keep the default options unless you know the consequences of changing them.
When the installer completes, it will ask to "Launch Stack Builder at exit?" -- keep this checked, as it is necessary to install PostGIS.
PostGISLink to this heading
From within the Stack Builder (to run outside of the installer, ), select from the drop down menu and click next. Expand the menu tree and select .
After clicking next, you will be prompted to confirm the selected package and "Download directory". Click next again, this will download PostGIS and you will be asked to click next to begin the PostGIS installer. Select the default options during install. The install process includes four Yes/No dialog boxes, the default option for all four is "No".
OSGeo4WLink to this heading
The OSGeo4W installer helps to install the PROJ, GDAL, and GEOS libraries required by GeoDjango. First, download the OSGeo4W installer, and run it. Select and click next. In the 'Select Packages' list, ensure that GDAL is selected. If any other packages are enabled by default, they are not required by GeoDjango and may be unchecked safely. After clicking next and accepting the license agreements, the packages will be automatically downloaded and installed, after which you may exit the installer.
Merubah lingkungan WindowsLink to this heading
In order to use GeoDjango, you will need to add your OSGeo4W
directories to your Windows system Path, as well as create GDAL_DATA
and PROJ_LIB environment variables. The following set of commands,
executable with cmd.exe, will set this up. Restart your device
once this is complete for new environment variables to be recognized:
set OSGEO4W_ROOT=C:\OSGeo4W
set GDAL_DATA=%OSGEO4W_ROOT%\apps\gdal\share\gdal
set PROJ_LIB=%OSGEO4W_ROOT%\share\proj
set PATH=%PATH%;%OSGEO4W_ROOT%\bin
reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_EXPAND_SZ /f /d "%PATH%"
reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v GDAL_DATA /t REG_EXPAND_SZ /f /d "%GDAL_DATA%"
reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROJ_LIB /t REG_EXPAND_SZ /f /d "%PROJ_LIB%"
Pasang Django dan setel basisdataLink to this heading
Install Django di sistem anda. Dianjurkan bahwa anda membuat virtual environment untuk setiap proyek anda buat.
psycopgLink to this heading
The psycopg Python module provides the interface between Python and the
PostgreSQL database. psycopg can be installed via pip within your Python
virtual environment:
...\> py -m pip install psycopg
Catatan kaki