182 | | |
183 | | == Installation == |
184 | | Installation of the GeoDjango module will also require the installation of existing open source geographic libraries and a spatial database (currently only PostGIS). This section will describe the installation process for these libraries. Initially, these instructions will pertain only to a Linux platform (particularly Debian or Ubuntu). Mac & Windows support will be considered later; however, these instructions will most likely work through the Mac shell. |
185 | | |
186 | | === Python & PostgreSQL === |
187 | | * '''Python''' |
188 | | * ''Required:'' Python 2.4 is required because of heavy use of 2.4 decorator syntax (''e.g.'' {{{@property}}}). The {{{ctypes}}} module needs to be installed as well. |
189 | | * ''Recommended:'' Python 2.5 is recommended because the {{{ctypes}}} module comes included. [http://www.python.org/download/releases/2.5.1/ Python 2.5.1] is the current latest. |
190 | | * '''PostgreSQL''' |
191 | | * ''Recommended:'' PostgreSQL 8.x. If installing binary packages, please install the development package as well for headers required in PostGIS compilation. |
192 | | * We are currently developing using both v8.1 and v8.2 of PostgreSQL. |
193 | | * On Ubuntu Feisty, you'll need the apt packages {{{postgresql-server-dev-8.x}}} (the development headers are needed for PostGIS compilation) and {{{postgresql-8.x}}}. |
194 | | * '''psycopg2''' |
195 | | * [http://initd.org/tracker/psycopg/wiki/PsycopgTwo psycopg2] is a Python database adapter for PostgreSQL. Latest version is [http://initd.org/pub/software/psycopg/psycopg2-2.0.6.tar.gz 2.0.6]. |
196 | | |
197 | | === Django === |
198 | | * GeoDjango exists in the {{{gis}}} branch from SVN: |
199 | | {{{ |
200 | | $ svn co http://code.djangoproject.com/svn/django/branches/gis django_gis |
201 | | $ ln -s django_gis/django /path/to/site-packages/django |
202 | | }}} |
203 | | |
204 | | === GEOS === |
205 | | * We have been developing using [http://geos.refractions.net/ GEOS] 3.0.0RC4, and have not tested or plan on supporting GEOS 2.x. |
206 | | * GeoDjango has its own GEOS {{{ctypes}}} wrapper; you do ''not'' need to enable the existing GEOS Python bindings. |
207 | | * {{{ctypes}}} comes standard with Python 2.5. If you run Python 2.4, {{{ctypes}}} may be [http://sourceforge.net/project/showfiles.php?group_id=71702&package_id=71318 downloaded here] |
208 | | * Configure, make, and install. |
209 | | {{{ |
210 | | $ ./configure |
211 | | $ make |
212 | | # make install |
213 | | }}} |
214 | | |
215 | | === PROJ.4 === |
216 | | * Latest [http://proj.maptools.org/ PROJ.4] version is 4.5.0. We have no reason to believe that previous versions (''e.g.'', 4.4.x, 4.3.x) will not work. |
217 | | * First, download the PROJ [ftp://ftp.remotesensing.org/proj/proj-datumgrid-1.3.tar.gz datum shifting files]. These will come in handy for coordinate transformations when other programs (like Mapserver or Mapnik) are not able to cope with EPSG transformations (I learned the hard way). Untar/unzip these in the {{{nad}}} subdirectory of the PROJ source. For example, if PROJ was unzipped in a directory named {{{proj}}}, then untar these files in {{{proj/nad}}}. Do this '''before''' you do the configure/make/install dance. |
218 | | * ''See'' [http://remotesensing.org/proj/faq.html PROJ FAQ]; ''see also'' [http://mapserver.gis.umn.edu/data2/wilma/mapserver-users/0301/msg00541.html Frank Warmerdam's reply to a Mapserver question]. |
219 | | * Next, configure, make and install. |
220 | | {{{ |
221 | | $ ./configure |
222 | | $ make |
223 | | # make install |
224 | | }}} |
225 | | |
226 | | === PostGIS === |
227 | | * '''Required''': PostGIS v1.1.0 and above. |
228 | | * '''Recommended''': Postgis v1.2.1 [http://postgis.refractions.net/download/ PostGIS] and greater. The latest version of PostGIS is [http://postgis.refractions.net/news/20070809/ v1.3.1] |
229 | | * First build & install PostGIS. |
230 | | {{{ |
231 | | $ ./configure --with-geos --with-proj |
232 | | $ make |
233 | | # make install |
234 | | }}} |
235 | | |
236 | | * Next, create a role and database for your application, and allow it to access PostGIS functionality: |
237 | | {{{ |
238 | | # su - postgres |
239 | | $ psql |
240 | | postgres=# CREATE ROLE <user> LOGIN; |
241 | | postgres=# \q |
242 | | $ createdb -O <user> <db_name> |
243 | | $ createlang plpgsql <db_name> |
244 | | $ psql -d <db_name> -f /usr/local/share/lwpostgis.sql |
245 | | $ psql -d <db_name> -f /usr/local/share/spatial_ref_sys.sql |
246 | | $ psql <db_name> |
247 | | <db_name>=# GRANT SELECT, UPDATE, INSERT, DELETE ON geometry_columns TO <user>; |
248 | | <db_name>=# GRANT SELECT ON spatial_ref_sys TO <user>; |
249 | | }}} |
250 | | |
251 | | * Finally, update your {{{settings.py}}} to reflect the name and user for the spatially enabled database. So far, we only plan to support the psycopg2 backend, thus: {{{DATABASE_ENGINE='postgresql_psycopg2'}}}. |
252 | | |
253 | | === GDAL === |
254 | | * ''Highly Recommended'': Some features (e.g. a large number of {{{SpatialRefSys}}} model routines) require GDAL, but it is not necessary for core functionality (e.g. spatial queries). |
255 | | * GDAL/OGR includes useful for coordinate transformations and reading/writing ''both'' vector (e.g. SHP) and raster (e.g. GeoTIFF) geographic data. |
256 | | * For example, the following command will convert your SHP file into [http://en.wikipedia.org/wiki/WGS84 WGS84] (standard lat/lon). Then you can import directly into your database using {{{shp2pgsql}}} (utility from PostGIS): |
257 | | {{{ |
258 | | ogr2ogr -t_srs WGS84 output.shp input.shp |
259 | | }}} |
260 | | * Latest [http://www.gdal.org/download.html GDAL] version is 1.4.2. Configure with GEOS then make (use {{{gmake}}} on Solaris platforms) and install: |
261 | | {{{ |
262 | | $ ./configure --with-geos |
263 | | $ make |
264 | | # make install |
265 | | }}} |
266 | | * As of r5397 there's a {{{ctypes}}} layer for GDAL/OGR, no additional Python bindings are needed. |
267 | | * If you still want to use the GDAL Python API for your own applications, then the following configuration flags: |
268 | | * {{{--with-python}}} {{{--without-ngpython}}}: the deprecated, but stable API. |
269 | | * {{{--without-python}}} {{{--with-ngpython}}}: the "next-generation" SWIG-based bindings -- used to problematic for Python 2.5 users, but the GDAL team has solved a lot of these issues in 1.4.2. |
270 | | * ''See generally'' [http://trac.osgeo.org/gdal/wiki/GdalOgrInPython GDAL/OGR In Python] on the GDAL trac wiki. |
271 | | |
272 | | === Windows === |
273 | | |
274 | | Though GeoDjango is not yet "officially" supported for Windows (due to documentation, see #4397), our ctypes interfaces have made compatibility with Windows 2000/XP a reality. The developer uses binary libraries from the following open-source projects (for Windows): |
275 | | * [http://www.postgis.org/news/20070319/ PostGIS 1.2.1 Windows Technology Preview]: Installs PostGIS 1.2.1 on Windows, and includes GEOS 3.0.0RC4 and proj libraries as well. |
276 | | * Copy {{{libgeos-3-0-0rc4.dll}}}, {{{libgeos_c-1.dll}}}, and {{{libproj.dll}}} to your Python directory (''e.g.'', {{{C:\Python25}}}) |
277 | | * [http://blog.qgis.org/?q=node/71 QGIS Windows 0.8.1 Release Candidate 1]: Installs QGIS, an open-source desktop application for GIS, similar to ArcView. Includes GDAL and its own proj libraries (more documentation forthcoming). |