~ubuntu-branches/ubuntu/quantal/python-django/quantal-security

« back to all changes in this revision

Viewing changes to docs/ref/contrib/gis/install.txt

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2010-10-12 11:34:35 UTC
  • mfrom: (4.4.9 sid)
  • mto: This revision was merged to the branch mainline in revision 30.
  • Revision ID: james.westby@ubuntu.com-20101012113435-5rk3p18nyanuhj6g
* SECURITY UPDATE: XSS in CSRF protections. New upstream release
  - CVE-2010-3082
* debian/patches/01_disable_url_verify_regression_tests.diff:
  - updated to disable another test that fails without internet connection
  - patch based on work by Kai Kasurinen and Krzysztof Klimonda
* debian/control: don't Build-Depends on locales-all, which doesn't exist
  in maverick

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
3. :ref:`geospatial_libs`
14
14
 
15
15
Details for each of the requirements and installation instructions
16
 
are provided in the sections below.   In addition, platform-specific 
 
16
are provided in the sections below.   In addition, platform-specific
17
17
instructions are available for:
18
18
 
19
19
* :ref:`macosx`
23
23
.. admonition:: Use the Source
24
24
 
25
25
    Because GeoDjango takes advantage of the latest in the open source geospatial
26
 
    software technology, recent versions of the libraries are necessary.  
 
26
    software technology, recent versions of the libraries are necessary.
27
27
    If binary packages aren't available for your platform,
28
28
    :ref:`installation from source <build_from_source>`
29
 
    may be required. When compiling the libraries from source, please follow the 
 
29
    may be required. When compiling the libraries from source, please follow the
30
30
    directions closely, especially if you're a beginner.
31
31
 
32
32
Requirements
37
37
Python 2.4+
38
38
-----------
39
39
Because of heavy use of the decorator syntax, Python 2.4 is minimum
40
 
version supported by GeoDjango. Python 2.5+ is recommended because the 
41
 
`ctypes`__ module comes included; otherwise, 2.4 users will need to 
 
40
version supported by GeoDjango. Python 2.5+ is recommended because the
 
41
`ctypes`__ module comes included; otherwise, 2.4 users will need to
42
42
`download and install ctypes`__.
43
43
 
44
44
__ http://docs.python.org/lib/module-ctypes.html
50
50
------
51
51
 
52
52
Because GeoDjango is included with Django, please refer to Django's
53
 
:ref:`installation instructions <intro-install>` for details on how to install.
 
53
:doc:`installation instructions </intro/install>` for details on how to install.
54
54
 
55
55
.. _spatial_database:
56
56
 
57
57
Spatial Database
58
58
----------------
59
 
PostgreSQL (with PostGIS), MySQL, Oracle, and SQLite (with SpatiaLite) are 
 
59
PostgreSQL (with PostGIS), MySQL, Oracle, and SQLite (with SpatiaLite) are
60
60
the spatial databases currently supported.
61
61
 
62
62
.. note::
63
63
 
64
 
    PostGIS is recommended, because it is the most mature and feature-rich 
 
64
    PostGIS is recommended, because it is the most mature and feature-rich
65
65
    open source spatial database.
66
66
 
67
67
The geospatial libraries required for a GeoDjango installation depends
81
81
 
82
82
Geospatial Libraries
83
83
--------------------
84
 
GeoDjango uses and/or provides interfaces for the the following open source 
 
84
GeoDjango uses and/or provides interfaces for the the following open source
85
85
geospatial libraries:
86
86
 
87
87
========================  ====================================  ================================  ==========================
117
117
====================
118
118
 
119
119
When installing from source on UNIX and GNU/Linux systems, please follow
120
 
the installation instructions carefully, and install the libraries in the 
 
120
the installation instructions carefully, and install the libraries in the
121
121
given order.  If using MySQL or Oracle as the spatial database, only GEOS
122
122
is required.
123
123
 
147
147
geometries).  Specifically, the C API library is called (e.g., ``libgeos_c.so``)
148
148
directly from Python using ctypes.
149
149
 
150
 
First, download GEOS 3.2 from the refractions website and untar the source 
 
150
First, download GEOS 3.2 from the refractions website and untar the source
151
151
archive::
152
152
 
153
153
    $ wget http://download.osgeo.org/geos/geos-3.2.2.tar.bz2
154
154
    $ tar xjf geos-3.2.2.tar.bz2
155
155
 
156
 
Next, change into the directory where GEOS was unpacked, run the configure 
 
156
Next, change into the directory where GEOS was unpacked, run the configure
157
157
script, compile, and install::
158
158
 
159
159
    $ cd geos-3.2.2
172
172
 
173
173
    ImportError: Could not find the GEOS library (tried "geos_c"). Try setting GEOS_LIBRARY_PATH in your settings.
174
174
 
175
 
The most common solution is to properly configure your :ref:`libsettings` *or* set 
 
175
The most common solution is to properly configure your :ref:`libsettings` *or* set
176
176
:ref:`geoslibrarypath` in your settings.
177
177
 
178
178
If using a binary package of GEOS (e.g., on Ubuntu 8.10), you may need to :ref:`binutils`.
191
191
 
192
192
.. note::
193
193
 
194
 
    The setting must be the *full* path to the **C** shared library; in 
 
194
    The setting must be the *full* path to the **C** shared library; in
195
195
    other words you want to use ``libgeos_c.so``, not ``libgeos.so``.
196
196
 
197
197
.. _proj4:
199
199
PROJ.4
200
200
------
201
201
 
202
 
`PROJ.4`_ is a library for converting geospatial data to different coordinate 
 
202
`PROJ.4`_ is a library for converting geospatial data to different coordinate
203
203
reference systems.
204
204
 
205
205
First, download the PROJ.4 source code and datum shifting files [#]_::
228
228
-------
229
229
 
230
230
`PostGIS`__ adds geographic object support to PostgreSQL, turning it
231
 
into a spatial database. :ref:`geosbuild` and :ref:`proj4` should be 
 
231
into a spatial database. :ref:`geosbuild` and :ref:`proj4` should be
232
232
installed prior to building PostGIS.
233
233
 
234
234
.. note::
235
235
 
236
 
    The `psycopg2`_ module is required for use as the database adaptor 
 
236
    The `psycopg2`_ module is required for use as the database adaptor
237
237
    when using GeoDjango with PostGIS.
238
238
 
239
239
.. _psycopg2: http://initd.org/projects/psycopg2
256
256
 
257
257
.. note::
258
258
 
259
 
    GeoDjango does not automatically create a spatial database.  Please 
 
259
    GeoDjango does not automatically create a spatial database.  Please
260
260
    consult the section on :ref:`spatialdb_template` for more information.
261
261
 
262
262
__ http://postgis.refractions.net/
267
267
----
268
268
 
269
269
`GDAL`__ is an excellent open source geospatial library that has support for
270
 
reading most vector and raster spatial data formats.  Currently, GeoDjango only 
 
270
reading most vector and raster spatial data formats.  Currently, GeoDjango only
271
271
supports :ref:`GDAL's vector data <ref-gdal>` capabilities [#]_.
272
272
:ref:`geosbuild` and :ref:`proj4` should be installed prior to building GDAL.
273
273
 
287
287
.. note::
288
288
 
289
289
   Because GeoDjango has it's own Python interface, the preceding instructions
290
 
   do not build GDAL's own Python bindings.  The bindings may be built by 
 
290
   do not build GDAL's own Python bindings.  The bindings may be built by
291
291
   adding the ``--with-python`` flag when running ``configure``.  See
292
 
   `GDAL/OGR In Python`__ for more information on GDAL's bindings. 
 
292
   `GDAL/OGR In Python`__ for more information on GDAL's bindings.
293
293
 
294
 
If you have any problems, please see the troubleshooting section below for 
 
294
If you have any problems, please see the troubleshooting section below for
295
295
suggestions and solutions.
296
296
 
297
297
__ http://trac.osgeo.org/gdal/
312
312
    >>> gdal.HAS_GDAL
313
313
    False
314
314
 
315
 
The solution is to properly configure your :ref:`libsettings` *or* set 
 
315
The solution is to properly configure your :ref:`libsettings` *or* set
316
316
:ref:`gdallibrarypath` in your settings.
317
317
 
318
318
.. _gdallibrarypath:
332
332
Can't find GDAL data files (``GDAL_DATA``)
333
333
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
334
334
 
335
 
When installed from source, GDAL versions 1.5.1 and below have an autoconf bug 
336
 
that places data in the wrong location. [#]_   This can lead to error messages 
 
335
When installed from source, GDAL versions 1.5.1 and below have an autoconf bug
 
336
that places data in the wrong location. [#]_   This can lead to error messages
337
337
like this::
338
338
 
339
339
    ERROR 4: Unable to open EPSG support file gcs.csv.
340
340
    ...
341
341
    OGRException: OGR failure.
342
342
 
343
 
The solution is to set the ``GDAL_DATA`` environment variable to the location of the 
344
 
GDAL data files before invoking Python  (typically ``/usr/local/share``; use 
 
343
The solution is to set the ``GDAL_DATA`` environment variable to the location of the
 
344
GDAL data files before invoking Python  (typically ``/usr/local/share``; use
345
345
``gdal-config --datadir`` to find out). For example::
346
346
 
347
347
    $ export GDAL_DATA=`gdal-config --datadir`
348
348
    $ python manage.py shell
349
349
 
350
 
If using Apache, you may need to add this environment variable to your configuration 
 
350
If using Apache, you may need to add this environment variable to your configuration
351
351
file::
352
352
 
353
353
    SetEnv GDAL_DATA /usr/local/share
363
363
   Mac OS X users should follow the instructions in the :ref:`kyngchaos` section,
364
364
   as it is much easier than building from source.
365
365
 
366
 
`SpatiaLite`__ adds spatial support to SQLite, turning it into a full-featured 
 
366
`SpatiaLite`__ adds spatial support to SQLite, turning it into a full-featured
367
367
spatial database.  Because SpatiaLite has special requirements, it typically
368
 
requires SQLite and pysqlite2 (the Python SQLite DB-API adaptor) to be built from 
 
368
requires SQLite and pysqlite2 (the Python SQLite DB-API adaptor) to be built from
369
369
source.  :ref:`geosbuild` and :ref:`proj4` should be installed prior to building
370
370
SpatiaLite.
371
371
 
372
 
After installation is complete, don't forget to read the post-installation 
 
372
After installation is complete, don't forget to read the post-installation
373
373
docs on :ref:`create_spatialite_db`.
374
374
 
375
375
__ http://www.gaia-gis.it/spatialite/index.html
380
380
^^^^^^
381
381
 
382
382
Typically, SQLite packages are not compiled to include the `R*Tree module`__ --
383
 
thus it must be compiled from source.  First download the latest amalgamation 
 
383
thus it must be compiled from source.  First download the latest amalgamation
384
384
source archive from the `SQLite download page`__, and extract::
385
385
 
386
 
    $ wget http://www.sqlite.org/sqlite-amalgamation-3.6.22.tar.gz
387
 
    $ tar xzf sqlite-amalgamation-3.6.22.tar.gz
388
 
    $ cd sqlite-3.6.22
 
386
    $ wget http://sqlite.org/sqlite-amalgamation-3.6.23.1.tar.gz
 
387
    $ tar xzf sqlite-amalgamation-3.6.23.1.tar.gz
 
388
    $ cd sqlite-3.6.23.1
389
389
 
390
390
Next, run the ``configure`` script -- however the ``CFLAGS`` environment variable
391
391
needs to be customized so that SQLite knows to build the R*Tree module::
398
398
.. note::
399
399
 
400
400
    If using Ubuntu, installing a newer SQLite from source can be very difficult
401
 
    because it links to the existing ``libsqlite3.so`` in ``/usr/lib`` which 
 
401
    because it links to the existing ``libsqlite3.so`` in ``/usr/lib`` which
402
402
    many other packages depend on.  Unfortunately, the best solution at this time
403
403
    is to overwrite the existing library by adding ``--prefix=/usr`` to the
404
404
    ``configure`` command.
420
420
    $ tar xzf spatialite-tools-2.3.1.tar.gz
421
421
 
422
422
Prior to attempting to build, please read the important notes below to see if
423
 
customization of the ``configure`` command is necessary.  If not, then run the 
 
423
customization of the ``configure`` command is necessary.  If not, then run the
424
424
``configure`` script, make, and install for the SpatiaLite library::
425
425
 
426
426
    $ cd libspatialite-amalgamation-2.3.1
431
431
 
432
432
Finally, do the same for the SpatiaLite tools::
433
433
 
434
 
    $ cd spatialite-tools-2.3.1   
 
434
    $ cd spatialite-tools-2.3.1
435
435
    $ ./configure # May need to modified, see notes below.
436
436
    $ make
437
437
    $ sudo make install
440
440
.. note::
441
441
 
442
442
    If you've installed GEOS and PROJ.4 from binary packages, you will have to specify
443
 
    their paths when running the ``configure`` scripts for *both* the library and the 
444
 
    tools (the configure scripts look, by default, in ``/usr/local``).  For example, 
 
443
    their paths when running the ``configure`` scripts for *both* the library and the
 
444
    tools (the configure scripts look, by default, in ``/usr/local``).  For example,
445
445
    on Debian/Ubuntu distributions that have GEOS and PROJ.4 packages, the command would be::
446
 
    
 
446
 
447
447
       $ ./configure --with-proj-include=/usr/include --with-proj-lib=/usr/lib --with-geos-include=/usr/include --with-geos-lib=/usr/lib
448
448
 
449
449
.. note::
450
450
 
451
 
    For Mac OS X users building from source, the SpatiaLite library *and* tools 
452
 
    need to be linked into the existing ``iconv`` library. While this happens 
453
 
    automatically on Linux, the ``configure`` scripts need to know about the 
454
 
    specific location on Mac OS X (via modification of the ``CFLAGS`` and 
455
 
    ``LDFLAGS`` environment variables prior to configuration)::
 
451
    For Mac OS X users building from source, the SpatiaLite library *and* tools
 
452
    need to have their ``target`` configured::
456
453
 
457
 
        $ CFLAGS=-I/usr/include LDFLAGS="-L/usr/lib -liconv" ./configure
 
454
        $ ./configure --target=macosx
458
455
 
459
456
__ http://www.gaia-gis.it/spatialite/sources.html
460
457
 
466
463
Because SpatiaLite must be loaded as an external extension, it requires the
467
464
``enable_load_extension`` method, which is only available in versions 2.5+.
468
465
Thus, download pysqlite2 2.6, and untar::
469
 
  
 
466
 
470
467
    $ wget http://pysqlite.googlecode.com/files/pysqlite-2.6.0.tar.gz
471
468
    $ tar xzf pysqlite-2.6.0.tar.gz
472
469
    $ cd pysqlite-2.6.0
487
484
    ``define=SQLITE_OMIT_LOAD_EXTENSION`` flag and that the ``include_dirs``
488
485
    and ``library_dirs`` settings are uncommented and set to the appropriate
489
486
    path if the SQLite header files and libraries are not in ``/usr/include``
490
 
    and ``/usr/lib``, respectively.   
 
487
    and ``/usr/lib``, respectively.
491
488
 
492
489
After modifying ``setup.cfg`` appropriately, then run the ``setup.py`` script
493
490
to build and install::
503
500
------------------------------------------------
504
501
 
505
502
Creating a spatial database with PostGIS is different than normal because
506
 
additional SQL must be loaded to enable spatial functionality.  Because of 
 
503
additional SQL must be loaded to enable spatial functionality.  Because of
507
504
the steps in this process, it's better to create a database template that
508
505
can be reused later.
509
506
 
521
518
   version 1.5 uses ``<sharedir>/contrib/postgis-1.5/postgis.sql``.
522
519
 
523
520
   The example below assumes PostGIS 1.5, thus you may need to modify
524
 
   ``POSTGIS_SQL_PATH`` and the name of the SQL file for the specific 
 
521
   ``POSTGIS_SQL_PATH`` and the name of the SQL file for the specific
525
522
   version of PostGIS you are using.
526
523
 
527
524
Once you're a database super user, then you may execute the following commands
601
598
Add ``django.contrib.gis`` to ``INSTALLED_APPS``
602
599
------------------------------------------------
603
600
 
604
 
Like other Django contrib applications, you will *only* need to add 
 
601
Like other Django contrib applications, you will *only* need to add
605
602
:mod:`django.contrib.gis` to :setting:`INSTALLED_APPS` in your settings.
606
603
This is the so that ``gis`` templates can be located -- if not done, then
607
604
features such as the geographic admin or KML sitemaps will not function properly.
633
630
    In Django 1.1 the name of this function is ``add_postgis_srs``.
634
631
 
635
632
This adds an entry for the 900913 SRID to the ``spatial_ref_sys`` (or equivalent)
636
 
table, making it possible for the spatial database to transform coordinates in 
 
633
table, making it possible for the spatial database to transform coordinates in
637
634
this projection.  You only need to execute this command *once* per spatial database.
638
635
 
639
636
Troubleshooting
643
640
community!  You can:
644
641
 
645
642
* Join the ``#geodjango`` IRC channel on FreeNode (may be accessed on the
646
 
  web via `Mibbit`__).  Please be patient and polite -- while you may not 
647
 
  get an immediate response, someone will attempt to answer your question 
 
643
  web via `Mibbit`__).  Please be patient and polite -- while you may not
 
644
  get an immediate response, someone will attempt to answer your question
648
645
  as soon as they see it.
649
646
* Ask your question on the `GeoDjango`__ mailing list.
650
647
* File a ticket on the `Django trac`__ if you think there's a bug.  Make
662
659
 
663
660
By far, the most common problem when installing GeoDjango is that the
664
661
external shared libraries (e.g., for GEOS and GDAL) cannot be located. [#]_
665
 
Typically, the cause of this problem is that the operating system isn't aware 
 
662
Typically, the cause of this problem is that the operating system isn't aware
666
663
of the directory where the libraries built from source were installed.
667
664
 
668
665
In general, the library path may be set on a per-user basis by setting
673
670
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
674
671
 
675
672
A user may set this environment variable to customize the library paths
676
 
they want to use.  The typical library directory for software 
 
673
they want to use.  The typical library directory for software
677
674
built from source is ``/usr/local/lib``.  Thus, ``/usr/local/lib`` needs
678
 
to be included in the ``LD_LIBRARY_PATH`` variable.  For example, the user 
 
675
to be included in the ``LD_LIBRARY_PATH`` variable.  For example, the user
679
676
could place the following in their bash profile::
680
677
 
681
678
    export LD_LIBRARY_PATH=/usr/local/lib
685
682
 
686
683
On GNU/Linux systems, there is typically a file in ``/etc/ld.so.conf``, which may include
687
684
additional paths from files in another directory, such as ``/etc/ld.so.conf.d``.
688
 
As the root user, add the custom library path (like ``/usr/local/lib``) on a  
 
685
As the root user, add the custom library path (like ``/usr/local/lib``) on a
689
686
new line in ``ld.so.conf``.  This is *one* example of how to do so::
690
687
 
691
688
    $ sudo echo /usr/local/lib >> /etc/ld.so.conf
705
702
 
706
703
GeoDjango uses the ``find_library`` function (from the ``ctypes.util`` Python
707
704
module) to discover libraries.  The ``find_library`` routine uses a program
708
 
called ``objdump`` (part of the ``binutils`` package) to verify a shared 
 
705
called ``objdump`` (part of the ``binutils`` package) to verify a shared
709
706
library on GNU/Linux systems.  Thus, if ``binutils`` is not installed on your
710
 
Linux system then Python's ctypes may not be able to find your library even if 
 
707
Linux system then Python's ctypes may not be able to find your library even if
711
708
your library path is set correctly and geospatial libraries were built perfectly.
712
709
 
713
710
The ``binutils`` package may be installed on Debian and Ubuntu systems using the
738
735
.. note::
739
736
 
740
737
    Currently, the easiest and recommended approach for installing GeoDjango
741
 
    on OS X is to use the KyngChaos packages.  
 
738
    on OS X is to use the KyngChaos packages.
742
739
 
743
 
This section also includes instructions for installing an upgraded version 
744
 
of :ref:`macosx_python` from packages provided by the Python Software 
 
740
This section also includes instructions for installing an upgraded version
 
741
of :ref:`macosx_python` from packages provided by the Python Software
745
742
Foundation, however, this is not required.
746
743
 
747
744
.. _macosx_python:
750
747
^^^^^^
751
748
 
752
749
Although OS X comes with Python installed, users can use framework
753
 
installers (`2.5`__ and `2.6`__ are available) provided by 
754
 
the Python Software Foundation.  An advantage to using the installer is 
 
750
installers (`2.5`__ and `2.6`__ are available) provided by
 
751
the Python Software Foundation.  An advantage to using the installer is
755
752
that OS X's Python will remain "pristine" for internal operating system
756
753
use.
757
754
 
759
756
__ http://python.org/ftp/python/2.6.2/python-2.6.2-macosx2009-04-16.dmg
760
757
 
761
758
.. note::
762
 
  
 
759
 
763
760
    You will need to modify the ``PATH`` environment variable in your
764
761
    ``.profile`` file so that the new version of Python is used when
765
762
    ``python`` is entered at the command-line::
771
768
KyngChaos Packages
772
769
^^^^^^^^^^^^^^^^^^
773
770
 
774
 
William Kyngesburye provides a number of `geospatial library binary packages`__ 
775
 
that make it simple to get GeoDjango installed on OS X without compiling 
 
771
William Kyngesburye provides a number of `geospatial library binary packages`__
 
772
that make it simple to get GeoDjango installed on OS X without compiling
776
773
them from source.  However, the `Apple Developer Tools`_ are still necessary
777
774
for compiling the Python database adapters :ref:`psycopg2_kyngchaos` (for PostGIS)
778
 
and :ref:`pysqlite2_kyngchaos` (for SpatiaLite).  
 
775
and :ref:`pysqlite2_kyngchaos` (for SpatiaLite).
779
776
 
780
777
.. note::
781
778
 
782
 
    SpatiaLite users should consult the :ref:`spatialite_kyngchaos` section 
 
779
    SpatiaLite users should consult the :ref:`spatialite_kyngchaos` section
783
780
    after installing the packages for additional instructions.
784
781
 
785
782
Download the framework packages for:
804
801
    export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH
805
802
    export PATH=/usr/local/pgsql/bin:$PATH
806
803
 
807
 
__ http://www.kyngchaos.com/wiki/software:frameworks
808
 
__ http://www.kyngchaos.com/wiki/software:postgres
 
804
__ http://www.kyngchaos.com/software/frameworks
 
805
__ http://www.kyngchaos.com/software/postgres
809
806
 
810
807
.. note::
811
808
 
837
834
pysqlite2
838
835
~~~~~~~~~
839
836
 
840
 
Follow the :ref:`pysqlite2` source install instructions, however, 
 
837
Follow the :ref:`pysqlite2` source install instructions, however,
841
838
when editing the ``setup.cfg`` use the following instead::
842
839
 
843
840
    [build_ext]
854
851
 
855
852
When :ref:`create_spatialite_db`, the ``spatialite`` program is required.
856
853
However, instead of attempting to compile the SpatiaLite tools from source,
857
 
download the `SpatiaLite Binaries`__ for OS X, and install ``spatialite`` in a 
 
854
download the `SpatiaLite Binaries`__ for OS X, and install ``spatialite`` in a
858
855
location available in your ``PATH``.  For example::
859
856
 
860
857
    $ curl -O http://www.gaia-gis.it/spatialite/spatialite-tools-osx-x86-2.3.1.tar.gz
890
887
MacPorts
891
888
^^^^^^^^
892
889
 
893
 
`MacPorts`__ may be used to install GeoDjango prerequisites on Macintosh 
 
890
`MacPorts`__ may be used to install GeoDjango prerequisites on Macintosh
894
891
computers running OS X.  Because MacPorts still builds the software from source,
895
 
the `Apple Developer Tools`_ are required. 
 
892
the `Apple Developer Tools`_ are required.
896
893
 
897
894
Summary::
898
895
 
901
898
    $ sudo port install proj
902
899
    $ sudo port install postgis
903
900
    $ sudo port install gdal
904
 
    $ sudo port install libgeoip  
 
901
    $ sudo port install libgeoip
905
902
 
906
903
.. note::
907
904
 
932
929
8.04 and lower
933
930
~~~~~~~~~~~~~~
934
931
 
935
 
The 8.04 (and lower) versions of Ubuntu use GEOS v2.2.3 in their binary packages, 
936
 
which is incompatible with GeoDjango.  Thus, do *not* use the binary packages 
937
 
for GEOS or PostGIS and build some prerequisites from source, per the instructions 
 
932
The 8.04 (and lower) versions of Ubuntu use GEOS v2.2.3 in their binary packages,
 
933
which is incompatible with GeoDjango.  Thus, do *not* use the binary packages
 
934
for GEOS or PostGIS and build some prerequisites from source, per the instructions
938
935
in this document; however, it is okay to use the PostgreSQL binary packages.
939
936
 
940
937
For more details, please see the Debian instructions for :ref:`etch` below.
973
970
* ``python-gdal`` for GDAL's own Python bindings -- includes interfaces for raster manipulation
974
971
 
975
972
.. note::
976
 
   
 
973
 
977
974
    The Ubuntu ``proj`` package does not come with the datum shifting files
978
 
    installed, which will cause problems with the geographic admin because 
 
975
    installed, which will cause problems with the geographic admin because
979
976
    the ``null`` datum grid is not available for transforming geometries to the
980
 
    spherical mercator projection. A solution is to download the 
 
977
    spherical mercator projection. A solution is to download the
981
978
    datum-shifting files, create the grid file, and install it yourself::
982
979
 
983
980
        $ wget http://download.osgeo.org/proj/proj-datumgrid-1.4.tar.gz
988
985
        $ sudo cp null /usr/share/proj
989
986
 
990
987
    Otherwise, the Ubuntu ``proj`` package is fine for general use as long as you
991
 
    do not plan on doing any database transformation of geometries to the 
 
988
    do not plan on doing any database transformation of geometries to the
992
989
    Google projection (900913).
993
990
 
994
991
.. note::
1035
1032
Source Packages
1036
1033
~~~~~~~~~~~~~~~
1037
1034
You will still have to install :ref:`geosbuild`, :ref:`proj4`,
1038
 
:ref:`postgis`, and :ref:`gdalbuild` from source.  Please follow the 
 
1035
:ref:`postgis`, and :ref:`gdalbuild` from source.  Please follow the
1039
1036
directions carefully.
1040
1037
 
1041
1038
.. _lenny:
1042
1039
 
1043
1040
5.0 (Lenny)
1044
1041
^^^^^^^^^^^
1045
 
This version is comparable to Ubuntu :ref:`ibex`, so the command 
 
1042
This version is comparable to Ubuntu :ref:`ibex`, so the command
1046
1043
is very similar::
1047
1044
 
1048
1045
    $ sudo apt-get install binutils libgdal1-1.5.0 postgresql-8.3 postgresql-8.3-postgis postgresql-server-dev-8.3 python-psycopg2 python-setuptools
1089
1086
^^^^^^
1090
1087
 
1091
1088
First, download the `Python 2.6 installer`__ from the Python website.  Next,
1092
 
execute the installer and use defaults, e.g., keep 'Install for all users' 
 
1089
execute the installer and use defaults, e.g., keep 'Install for all users'
1093
1090
checked and the installation path set as ``C:\Python26``.
1094
1091
 
1095
1092
.. note::
1096
1093
 
1097
1094
    You may already have a version of Python installed in ``C:\python`` as ESRI
1098
 
    products sometimes install a copy there.  *You should still install a 
 
1095
    products sometimes install a copy there.  *You should still install a
1099
1096
    fresh version of Python 2.6.*
1100
1097
 
1101
1098
__ http://python.org/ftp/python/2.6.2/python-2.6.2.msi
1110
1107
 
1111
1108
   PostgreSQL 8.3 is required because PostGIS is not available yet for 8.4.
1112
1109
 
1113
 
After downloading, simply click on the installer, follow the 
1114
 
on-screen directions, and keep the default options (e.g., keep the installation 
 
1110
After downloading, simply click on the installer, follow the
 
1111
on-screen directions, and keep the default options (e.g., keep the installation
1115
1112
path as ``C:\Program Files\PostgreSQL\8.3``).
1116
1113
 
1117
1114
.. note::
1118
1115
 
1119
 
    This PostgreSQL installation process will create both a new windows user to be the 
1120
 
    'postgres service account' and a special 'postgres superuser' to own the database 
1121
 
    cluster. You will be prompted to set a password for both users (make sure to write 
1122
 
    them down!). To see basic details on the 'service user' account right click on 
1123
 
    'My Computer' and select 'Manage' or go to: Control Panel -> Administrative Tools -> 
 
1116
    This PostgreSQL installation process will create both a new windows user to be the
 
1117
    'postgres service account' and a special 'postgres superuser' to own the database
 
1118
    cluster. You will be prompted to set a password for both users (make sure to write
 
1119
    them down!). To see basic details on the 'service user' account right click on
 
1120
    'My Computer' and select 'Manage' or go to: Control Panel -> Administrative Tools ->
1124
1121
    Computer Management -> System Tools -> Local Users and Groups.
1125
1122
 
1126
 
If installed successfully, the PostgreSQL server will run in the background each time 
1127
 
the system as started as a Windows service.  When finished, the installer should launch 
 
1123
If installed successfully, the PostgreSQL server will run in the background each time
 
1124
the system as started as a Windows service.  When finished, the installer should launch
1128
1125
the Application Stack Builder (ASB) -- use this to install PostGIS, see instructions
1129
1126
below for more details.  A 'PostgreSQL 8.3' start menu group should be created that
1130
1127
contains shortcuts for the ASB and 'Command Prompt', which launches a terminal window
1135
1132
PostGIS
1136
1133
^^^^^^^
1137
1134
 
1138
 
From the Application Stack Builder (Programs -> PostgreSQL 8.3), select 
1139
 
'PostgreSQL Database Server 8.3 on port 5432' from the drop down menu.  Next, 
 
1135
From the Application Stack Builder (Programs -> PostgreSQL 8.3), select
 
1136
'PostgreSQL Database Server 8.3 on port 5432' from the drop down menu.  Next,
1140
1137
select 'PostGIS 1.3.6 for PostgreSQL 8.3' from the 'Spatial Extensions' tree
1141
 
in the list.  Select only the default options during install (do not uncheck 
 
1138
in the list.  Select only the default options during install (do not uncheck
1142
1139
the option to create a default PostGIS database).
1143
1140
 
1144
1141
.. note::
1145
1142
 
1146
 
    You will be prompted to enter your 'postgres superuser' password in the 
 
1143
    You will be prompted to enter your 'postgres superuser' password in the
1147
1144
    'Database Connection Information' dialog.
1148
1145
 
1149
1146
psycopg2
1150
1147
^^^^^^^^
1151
1148
 
1152
1149
The ``psycopg2`` Python module provides the interface between Python and the
1153
 
PostgreSQL database.  Download the `Windows installer`__ (v2.0.10) and run 
 
1150
PostgreSQL database.  Download the `Windows installer`__ (v2.0.10) and run
1154
1151
using the default settings. [#]_
1155
1152
 
1156
1153
__ http://www.stickpeople.com/projects/python/win-psycopg/psycopg2-2.0.10.win32-py2.6-pg8.3.7-release.exe
1163
1160
automatically installs Django 1.1, GDAL 1.6.0, PROJ 4.6.1 (including datum grid
1164
1161
files), and configures the necessary environment variables.
1165
1162
 
1166
 
Once the installer has completed, log out and log back in so that the 
 
1163
Once the installer has completed, log out and log back in so that the
1167
1164
modifications to the system environment variables take effect, and you
1168
1165
should be good to go.
1169
1166
 
1170
1167
.. note::
1171
1168
 
1172
1169
    The installer modifies the system ``Path`` environment variable to
1173
 
    include ``C:\Program Files\PostgreSQL\8.3\bin`` and 
 
1170
    include ``C:\Program Files\PostgreSQL\8.3\bin`` and
1174
1171
    ``C:\Program Files\GeoDjango\bin``.  This is required so that Python
1175
1172
    may find the GEOS DLL provided by PostGIS and the GDAL DLL provided
1176
 
    by the installer. The installer also sets the ``GDAL_DATA`` and 
 
1173
    by the installer. The installer also sets the ``GDAL_DATA`` and
1177
1174
    ``PROJ_LIB`` environment variables.
1178
1175
 
1179
1176
__ http://geodjango.org/windows/GeoDjango_Installer.exe
1180
1177
 
1181
1178
.. rubric:: Footnotes
1182
1179
.. [#] The datum shifting files are needed for converting data to and from certain projections.
1183
 
       For example, the PROJ.4 string for the `Google projection (900913) <http://spatialreference.org/ref/epsg/900913/proj4>`_ 
1184
 
       requires the ``null`` grid file only included in the extra datum shifting files.  
 
1180
       For example, the PROJ.4 string for the `Google projection (900913) <http://spatialreference.org/ref/epsg/900913/proj4>`_
 
1181
       requires the ``null`` grid file only included in the extra datum shifting files.
1185
1182
       It is easier to install the shifting files now, then to have debug a problem caused by their absence later.
1186
1183
.. [#] Specifically, GeoDjango provides support for the `OGR <http://gdal.org/ogr>`_ library, a component of GDAL.
1187
1184
.. [#] See `GDAL ticket #2382 <http://trac.osgeo.org/gdal/ticket/2382>`_.
1188
1185
.. [#] GeoDjango uses the `find_library <http://docs.python.org/library/ctypes.html#finding-shared-libraries>`_
1189
 
       routine from ``ctypes.util`` to locate shared libraries. 
1190
 
.. [#] The ``psycopg2`` Windows installers are packaged and maintained by 
1191
 
       `Jason Erickson <http://www.stickpeople.com/projects/python/win-psycopg/>`_. 
1192
 
.. [#] The source code for the installer is available in the `nsis_installer <http://geodjango.org/hg/nsis_installer/>`_ 
 
1186
       routine from ``ctypes.util`` to locate shared libraries.
 
1187
.. [#] The ``psycopg2`` Windows installers are packaged and maintained by
 
1188
       `Jason Erickson <http://www.stickpeople.com/projects/python/win-psycopg/>`_.
 
1189
.. [#] The source code for the installer is available in the `nsis_installer <http://geodjango.org/hg/nsis_installer/>`_
1193
1190
       GeoDjango mercurial repository.