PostGIS
Contents
1. Installation
1.1. For Debian Linux
1.1.1. with postgis-package from Debian
aptitude install postgresql-8.1 postgresql-8.1-postgis postgresql-conrib-8.1
lwpostgis.sql and spatial_ref_sys.sql are stored in /usr/share/postgresql-8.1-postgis.
1.1.2. with postgis built from sources
- aptitude install build-essential
- apt-get build-dep postgresql
- aptitude install flex proj libgeos-dev
tar xvfz postgis-1.3.x.tar.gz cd postgis-1.3.x ./configure (perhaps you need to specifiy the parameter --with-pgsql=/usr/local/pgsql/bin/pg_config if PostgreSQL cannot be found) make make install
1.2. For Gentoo Linux
You should use the package.keywords and package.use files in /etc/portage/ in favor of environment variables!
gateway ~ # USE="geos proj" ACCEPT_KEYWORDS="~x86" emerge =postgis-1.0.1_p20050805 -vp These are the packages that I would merge, in order: Calculating dependencies ...done! [ebuild N ] dev-lang/swig-1.3.25 -X -doc -guile -java +perl +php +python -ruby -tcltk 3,370 kB [ebuild N ] sci-libs/geos-2.1.4 -doc +python -static 494 kB [ebuild N ] dev-python/egenix-mx-base-2.0.6 573 kB [ebuild N ] dev-db/libpq-8.1.2 -kerberos -nls +pam +readline +ssl +zlib 7,853 kB [ebuild N ] dev-db/postgresql-8.1.2 -doc -kerberos -libg++ -nls +pam +perl -pg-intdatetime +python +readline (-selinux) +ssl -tcltk +xml2 +zlib 140 kB [ebuild N ] sci-libs/proj-4.4.9 2,385 kB [ebuild N ] dev-db/postgis-1.0.1_p20050805 -doc +geos +proj 1,414 kB Total size of downloads: 16,232 kB
For even more actual versions of postgis you should obtain a copy of an ebuild from http://bugs.gentoo.org and place it in an portage overlay (see man 5 portage)
2. Creating a DB
createlang plpgsql yourtestdatabase psql -d yourtestdatabase -f lwpostgis.sql psql -d yourtestdatabase -f spatial_ref_sys.sql
3. Granting the users it's geometry Rights
db=# GRANT ALL ON geometry_columns TO PUBLIC;
db=# GRANT ALL ON spatial_ref_sys TO PUBLIC;
4. Checking Spatial Data
- Checking if geometries are valid against SFS
SELECT fnp1 FROM gruenflaechen where isvalid(the_geom) <> true;
5. Resources
Postgis form souces on Ubuntu (works for Debian too): http://postgis.refractions.net/support/wiki/index.php?PostgisOnUbuntu