Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updated GeoDjango installation docs and spatial database template scr…

…ipt for latest Ubuntu/Debian packages.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15520 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c7618d5fa642f608459b3eb50074c7039abb3709 1 parent c40a1d1
Justin Bronn authored
45  docs/ref/contrib/gis/create_template_postgis-debian.sh
... ...
@@ -1,9 +1,38 @@
1  
-#!/usr/bin/env bash
2  
-POSTGIS_SQL_PATH=/usr/share/postgresql-8.3-postgis
3  
-createdb -E UTF8 template_postgis # Create the template spatial database.
4  
-createlang -d template_postgis plpgsql # Adding PLPGSQL language support.
5  
-psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';"
6  
-psql -d template_postgis -f $POSTGIS_SQL_PATH/lwpostgis.sql # Loading the PostGIS SQL routines
7  
-psql -d template_postgis -f $POSTGIS_SQL_PATH/spatial_ref_sys.sql
8  
-psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;" # Enabling users to alter spatial tables.
  1
+#!/bin/bash
  2
+
  3
+# For Ubuntu 8.x and 9.x releases.
  4
+if [ -d "/usr/share/postgresql-8.3-postgis" ]
  5
+then
  6
+    POSTGIS_SQL_PATH=/usr/share/postgresql-8.3-postgis
  7
+    POSTGIS_SQL=lwpostgis.sql
  8
+fi
  9
+
  10
+# For Ubuntu 10.04
  11
+if [ -d "/usr/share/postgresql/8.4/contrib" ]
  12
+then
  13
+    POSTGIS_SQL_PATH=/usr/share/postgresql/8.4/contrib
  14
+    POSTGIS_SQL=postgis.sql
  15
+fi
  16
+
  17
+# For Ubuntu 10.10 (with PostGIS 1.5)
  18
+if [ -d "/usr/share/postgresql/8.4/contrib/postgis-1.5" ]
  19
+then
  20
+    POSTGIS_SQL_PATH=/usr/share/postgresql/8.4/contrib/postgis-1.5
  21
+    POSTGIS_SQL=postgis.sql
  22
+    GEOGRAPHY=1
  23
+else
  24
+    GEOGRAPHY=0
  25
+fi
  26
+
  27
+createdb -E UTF8 template_postgis && \
  28
+createlang -d template_postgis plpgsql && \
  29
+psql -d postgres -c "UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis';" && \
  30
+psql -d template_postgis -f $POSTGIS_SQL_PATH/$POSTGIS_SQL && \
  31
+psql -d template_postgis -f $POSTGIS_SQL_PATH/spatial_ref_sys.sql && \
  32
+psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;" && \
9 33
 psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;"
  34
+
  35
+if ((GEOGRAPHY))
  36
+then
  37
+    psql -d template_postgis -c "GRANT ALL ON geography_columns TO PUBLIC;"
  38
+fi
81  docs/ref/contrib/gis/install.txt
@@ -89,7 +89,7 @@ Program                   Description                           Required
89 89
 ========================  ====================================  ================================  ==========================
90 90
 :ref:`GEOS <ref-geos>`    Geometry Engine Open Source           Yes                               3.2, 3.1, 3.0
91 91
 `PROJ.4`_                 Cartographic Projections library      Yes (PostgreSQL and SQLite only)  4.7, 4.6, 4.5, 4.4
92  
-:ref:`GDAL <ref-gdal>`    Geospatial Data Abstraction Library   No (but, required for SQLite)     1.7, 1.6, 1.5, 1.4
  92
+:ref:`GDAL <ref-gdal>`    Geospatial Data Abstraction Library   No (but, required for SQLite)     1.8, 1.7, 1.6, 1.5, 1.4
93 93
 :ref:`GeoIP <ref-geoip>`  IP-based geolocation library          No                                1.4
94 94
 `PostGIS`__               Spatial extensions for PostgreSQL     Yes (PostgreSQL only)             1.5, 1.4, 1.3
95 95
 `SpatiaLite`__            Spatial extensions for SQLite         Yes (SQLite only)                 2.4, 2.3
@@ -176,7 +176,7 @@ When GeoDjango can't find GEOS, this error is raised::
176 176
 The most common solution is to properly configure your :ref:`libsettings` *or* set
177 177
 :ref:`geoslibrarypath` in your settings.
178 178
 
179  
-If using a binary package of GEOS (e.g., on Ubuntu 8.10), you may need to :ref:`binutils`.
  179
+If using a binary package of GEOS (e.g., on Ubuntu), you may need to :ref:`binutils`.
180 180
 
181 181
 .. _geoslibrarypath:
182 182
 
@@ -274,9 +274,9 @@ supports :ref:`GDAL's vector data <ref-gdal>` capabilities [#]_.
274 274
 
275 275
 First download the latest GDAL release version and untar the archive::
276 276
 
277  
-    $ wget http://download.osgeo.org/gdal/gdal-1.7.3.tar.gz
278  
-    $ tar xzf gdal-1.7.3.tar.gz
279  
-    $ cd gdal-1.7.3
  277
+    $ wget http://download.osgeo.org/gdal/gdal-1.8.0.tar.gz
  278
+    $ tar xzf gdal-1.8.0.tar.gz
  279
+    $ cd gdal-1.8.0
280 280
 
281 281
 Configure, make and install::
282 282
 
@@ -517,14 +517,15 @@ user.  For example, you can use the following to become the ``postgres`` user::
517 517
    whereas version 1.4 uses ``<sharedir>/contrib/postgis.sql`` and
518 518
    version 1.5 uses ``<sharedir>/contrib/postgis-1.5/postgis.sql``.
519 519
 
  520
+   To complicate matters, :ref:`ubuntudebian` distributions have their
  521
+   own separate directory naming system that changes each release.
  522
+
520 523
    The example below assumes PostGIS 1.5, thus you may need to modify
521 524
    ``POSTGIS_SQL_PATH`` and the name of the SQL file for the specific
522 525
    version of PostGIS you are using.
523 526
 
524 527
 Once you're a database super user, then you may execute the following commands
525  
-to create a PostGIS spatial database template.  If running Ubuntu :ref:`ibex`
526  
-or Debian :ref:`lenny`, please refer to their specific documentation for
527  
-modifications to these commands::
  528
+to create a PostGIS spatial database template::
528 529
 
529 530
     $ POSTGIS_SQL_PATH=`pg_config --sharedir`/contrib/postgis-1.5
530 531
     # Creating the template spatial database.
@@ -549,6 +550,7 @@ PostGIS Version  Shell Script
549 550
 1.3              `create_template_postgis-1.3.sh`_
550 551
 1.4              `create_template_postgis-1.4.sh`_
551 552
 1.5              `create_template_postgis-1.5.sh`_
  553
+Debian/Ubuntu    `create_template_postgis-debian.sh`_
552 554
 ===============  ==========================================
553 555
 
554 556
 Afterwards, you may create a spatial database by simply specifying
@@ -919,22 +921,30 @@ __ http://www.macports.org/
919 921
 Ubuntu & Debian GNU/Linux
920 922
 -------------------------
921 923
 
  924
+.. note::
  925
+
  926
+    The PostGIS SQL files are not placed the PostgreSQL share directory in the
  927
+    Debian and Ubuntu packages, and are located instead special directory
  928
+    depending on the release.  Thus, when :ref:`spatialdb_template` use the 
  929
+    `create_template_postgis-debian.sh`_ script instead 
  930
+
922 931
 .. _ubuntu:
923 932
 
924 933
 Ubuntu
925 934
 ^^^^^^
926 935
 
927  
-.. _heron:
  936
+.. _ubuntu10:
928 937
 
929  
-8.04 and lower
930  
-~~~~~~~~~~~~~~
  938
+10.04 and 10.10
  939
+~~~~~~~~~~~~~~~
931 940
 
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
935  
-in this document; however, it is okay to use the PostgreSQL binary packages.
  941
+In Ubuntu 10 PostgreSQL was upgraded to 8.4 and GDAL was upgraded to 1.6.
  942
+Ubuntu 10.04 uses PostGIS 1.4, while Ubuntu 10.10 uses PostGIS 1.5 (with
  943
+geography support).  The installation commands are::
936 944
 
937  
-For more details, please see the Debian instructions for :ref:`etch` below.
  945
+    $ sudo apt-get install binutils gdal-bin postgresql-8.4-postgis \
  946
+         postgresql-server-dev-8.4 python-psycopg2 python-setuptools
  947
+    $ sudo easy_install Django
938 948
 
939 949
 .. _ibex:
940 950
 
@@ -943,7 +953,7 @@ For more details, please see the Debian instructions for :ref:`etch` below.
943 953
 
944 954
 Use the synaptic package manager to install the following packages::
945 955
 
946  
-    $ sudo apt-get install binutils libgdal1-1.5.0 postgresql-8.3-postgis \
  956
+    $ sudo apt-get install binutils gdal-bin postgresql-8.3-postgis \
947 957
         postgresql-server-dev-8.3 python-psycopg2 python-setuptools
948 958
 
949 959
 Afterwards, you may install Django with Python's ``easy_install`` script (the
@@ -970,24 +980,14 @@ Optional packages to consider:
970 980
 * ``gdal-bin``: for GDAL command line programs like ``ogr2ogr``
971 981
 * ``python-gdal`` for GDAL's own Python bindings -- includes interfaces for raster manipulation
972 982
 
973  
-10.04
974  
-~~~~~
975  
-
976  
-In Ubuntu 10.04 LTS PostgreSQL was upgraded to 8.4, as was GDAL, which is now
977  
-at version 1.6.0. Because of that, the package installation mentioned above
978  
-has to be slightly changed::
979  
-
980  
-	$ sudo apt-get install binutils libgdal1-1.6.0 postgresql-8.4-postgis \
981  
-        postgresql-server-dev-8.4 python-psycopg2 python-setuptools
982  
-
983  
-
984 983
 .. note::
985 984
 
986  
-    The Ubuntu ``proj`` package does not come with the datum shifting files
987  
-    installed, which will cause problems with the geographic admin because
988  
-    the ``null`` datum grid is not available for transforming geometries to the
989  
-    spherical mercator projection. A solution is to download the
990  
-    datum-shifting files, create the grid file, and install it yourself::
  985
+    On this version of Ubuntu the ``proj`` package does not come with the
  986
+    datum shifting files installed, which will cause problems with the
  987
+    geographic admin because the ``null`` datum grid is not available for
  988
+    transforming geometries to the spherical mercator projection. A solution
  989
+    is to download the datum-shifting files, create the grid file, and
  990
+    install it yourself::
991 991
 
992 992
         $ wget http://download.osgeo.org/proj/proj-datumgrid-1.4.tar.gz
993 993
         $ mkdir nad
@@ -1000,11 +1000,17 @@ has to be slightly changed::
1000 1000
     do not plan on doing any database transformation of geometries to the
1001 1001
     Google projection (900913).
1002 1002
 
1003  
-.. note::
  1003
+.. _heron:
1004 1004
 
1005  
-    The PostGIS SQL files are not placed the PostgreSQL share directory in the
1006  
-    Ubuntu packages.  Use the `create_template_postgis-debian.sh`_ script
1007  
-    instead when :ref:`spatialdb_template`.
  1005
+8.04 and lower
  1006
+~~~~~~~~~~~~~~
  1007
+
  1008
+The 8.04 (and lower) versions of Ubuntu use GEOS v2.2.3 in their binary packages,
  1009
+which is incompatible with GeoDjango.  Thus, do *not* use the binary packages
  1010
+for GEOS or PostGIS and build some prerequisites from source, per the instructions
  1011
+in this document; however, it is okay to use the PostgreSQL binary packages.
  1012
+
  1013
+For more details, please see the Debian instructions for :ref:`etch` below.
1008 1014
 
1009 1015
 .. _debian:
1010 1016
 
@@ -1051,6 +1057,7 @@ directions carefully.
1051 1057
 
1052 1058
 5.0 (Lenny)
1053 1059
 ^^^^^^^^^^^
  1060
+
1054 1061
 This version is comparable to Ubuntu :ref:`ibex`, so the command
1055 1062
 is very similar::
1056 1063
 

0 notes on commit c7618d5

Please sign in to comment.
Something went wrong with that request. Please try again.