In the past I have always chosen to compile my own PostGIS because the GEOS library that came with the regular PostgreSQL yum install, was a bit antiquated. This has changed, so this time around I figured I'd give it a go at using the Yum repository 1.5.2 release of PostGIS available via Yum Package List.
Before you can follow these directions, make sure you have your PostgreSQL 9.0 setup via our An almost idiot's guide to Install PostgreSQL 9.0 with Yum.
Verify the postgis package is available with a:
yum list | grep postgis
You should see a list that looks like:
postgis90.i386 1.5.2-1.rhel5 pgdg90 postgis90-debuginfo.i386 1.5.2-1.rhel5 pgdg90 postgis90-docs.i386 1.5.2-1.rhel5 pgdg90 postgis90-utils.i386 1.5.2-1.rhel5 pgdg90
Now we do a:
yum install postgis90
Which should present a screen that looks like:
================================================================================ Package Arch Version Repository Size ================================================================================ Installing: postgis90 i386 1.5.2-1.rhel5 pgdg90 1.6 M Installing for dependencies: geos i386 3.2.2-1.rhel5 pgdg90 582 k proj i386 4.7.0-1.rhel5 pgdg90 162 k Transaction Summary ================================================================================ Install 3 Package(s) Upgrade 0 Package(s) Total download size: 2.3 M Is this ok [y/N]
Type y
If all goes well, you should get a screen that looks like this:
Downloading Packages: (1/3): proj-4.7.0-1.rhel5.i386.rpm | 162 kB 00:01 (2/3): geos-3.2.2-1.rhel5.i386.rpm | 582 kB 00:02 (3/3): postgis90-1.5.2-1.rhel5.i386.rpm | 1.6 MB 00:04 -------------------------------------------------------------------------------- Total 253 kB/s | 2.3 MB 00:09 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : geos 1/3 Installing : proj 2/3 Installing : postgis90 3/3 Installed: postgis90.i386 0:1.5.2-1.rhel5 Dependency Installed: geos.i386 0:3.2.2-1.rhel5 proj.i386 0:4.7.0-1.rhel5 Complete!
Okay now that we have that installed. All the PostGIS binaries and contribs are located by default in: /usr/pgsql-9.0
su postgres cd /usr/pgsql-9.0/share/contrib/postgis-1.5 ls
Should show you a screen that looks like:
postgis.sql postgis_upgrade_15_minor.sql postgis_upgrade_13_to_15.sql spatial_ref_sys.sql postgis_upgrade_14_to_15.sql uninstall_postgis.sql
The postgis_comments.sql file file that installs database psql/pgAdmin online help online help is not listed. The postgis installed docs are located in /usr/share/doc/postgis90-1.5.2, but I couldn't find the postgis_comments.sql file.
If you want that, it's located in the docs folder of the official PostGIS 1.5.2 source tar ball and you install it after you have installed postgis.sql.
To create a spatial database or spatially enable a non-spatial database we do this: Note for the GRANT - if you are not paranoid about security, you could set that to ALL. For geography_columns there isn't any reason to give update rights since its a view into the system tables.
psql -U postgres -p 5432
At the psql prompt do
create database template_postgis15; \c template_postgis15 \i postgis.sql \i spatial_ref_sys.sql GRANT SELECT ON geometry_columns TO PUBLIC; GRANT SELECT ON spatial_ref_sys TO PUBLIC; GRANT SELECT ON geography_columns TO PUBLIC; \c postgres UPDATE pg_database SET datistemplate='true' WHERE datname='template_postgis15'; CREATE ROLE mygisuser LOGIN PASSWORD 'whatever' CREATEDB; CREATE DATABASE mygisdb WITH ENCODING='UTF8' OWNER=mygisuser TEMPLATE=template_postgis15; \q #logs you out.
Now we connect as our user:
psql -h localhost -U mygisuser -p 5433 -d mygisdbSELECT postgis_full_version();
postgis_full_version ------------------------------------------------------------------------------------------------------- POSTGIS="1.5.2" GEOS="3.2.2-CAPI-1.6.2" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.6.26" USE_STATS
SELECT ST_AsText( ST_Centroid('LINESTRING(1 2, 3 4)'::geometry)); st_astext ------------ POINT(2 3)
Thought you would never ask. Well we've been playing with it on Windows, but have yet to compile and install on Linux. We will be doing that in the next week or so and write up a how to on that. I will say that the new features in PostGIS 2.0 are to put it lightly, mind blowing. We've got true 3D surfaces, topology, lots more processing functions, raster with mapalgebra and even export to JPEG etc which looks like it will make it into PostGIS 2.0. We have tiger geocoder with both geocoder and reverse gecoder functions to work with Tiger 2010 census. We have to cleanup the tiger loader for Linux a bit more and will do that before PostGIS 2.0 release. We've got X3D output and GML for surfaces to target CityGML needs. We have the whole world in our hands. I would say we've got a good 2 more months before we will be ready to release.