postgis.txt 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ==================
  2. Installing PostGIS
  3. ==================
  4. `PostGIS`__ adds geographic object support to PostgreSQL, turning it
  5. into a spatial database. :ref:`geosbuild`, :ref:`proj4` and
  6. :ref:`gdalbuild` should be installed prior to building PostGIS. You
  7. might also need additional libraries, see `PostGIS requirements`_.
  8. .. note::
  9. The `psycopg2`_ module is required for use as the database adapter
  10. when using GeoDjango with PostGIS.
  11. .. _psycopg2: http://initd.org/psycopg/
  12. .. _PostGIS requirements: http://postgis.net/docs/manual-2.1/postgis_installation.html#install_requirements
  13. On Debian/Ubuntu, you are advised to install the following packages:
  14. postgresql-x.x, postgresql-x.x-postgis, postgresql-server-dev-x.x,
  15. python-psycopg2 (x.x matching the PostgreSQL version you want to install).
  16. Please also consult platform-specific instructions if you are on :ref:`macosx`
  17. or :ref:`windows`.
  18. Building from source
  19. ====================
  20. First download the source archive, and extract::
  21. $ wget http://download.osgeo.org/postgis/source/postgis-2.1.5.tar.gz
  22. $ tar xzf postgis-2.1.5.tar.gz
  23. $ cd postgis-2.1.5
  24. Next, configure, make and install PostGIS::
  25. $ ./configure
  26. Finally, make and install::
  27. $ make
  28. $ sudo make install
  29. $ cd ..
  30. .. note::
  31. GeoDjango does not automatically create a spatial database. Please consult
  32. the section on :ref:`spatialdb_template91` for more information.
  33. __ http://postgis.net/
  34. Post-installation
  35. =================
  36. .. _spatialdb_template:
  37. .. _spatialdb_template91:
  38. Creating a spatial database
  39. ---------------------------
  40. PostGIS 2 includes an extension for Postgres 9.1+ that can be used to enable
  41. spatial functionality::
  42. $ createdb <db name>
  43. $ psql <db name>
  44. > CREATE EXTENSION postgis;
  45. GeoDjango does not currently leverage any `PostGIS topology functionality`__.
  46. If you plan to use those features at some point, you can also install the
  47. ``postgis_topology`` extension by issuing ``CREATE EXTENSION
  48. postgis_topology;``.
  49. __ http://postgis.net/docs/Topology.html
  50. .. versionchanged:: 1.8
  51. The ``CREATE EXTENSION postgis`` command is now automatically run during
  52. the :djadmin:`migrate` process. You can still create it manually if you
  53. wish.
  54. Managing the database
  55. ---------------------
  56. To administer the database, you can either use the pgAdmin III program
  57. (:menuselection:`Start --> PostgreSQL 9.x --> pgAdmin III`) or the
  58. SQL Shell (:menuselection:`Start --> PostgreSQL 9.x --> SQL Shell`).
  59. For example, to create a ``geodjango`` spatial database and user, the following
  60. may be executed from the SQL Shell as the ``postgres`` user::
  61. postgres# CREATE USER geodjango PASSWORD 'my_passwd';
  62. postgres# CREATE DATABASE geodjango OWNER geodjango;