template-postgis database

Create a template_postgis database Some might find this useful for creating PostGIS databases without having to be PostgreSQL super users. The idea is to create a template_postgis database, install plpgsql and postgis into it, and then use this database as a template when creating new PostGIS databases.

Now non-super users can create PostGIS databases using template_postgis:

$ createdb my_geo_db -W -T template_postgis

Geospatial @ RailsConf Europe 2007

railsconf_speaker Some great news for those interested in the convergence between Ruby/Rails and Geospatial applications. Kashif and I will be giving a tutorial at RailsConf in Berlin. There is going to be 3 hr tutorial titled Rails GIS Hacks, where we will be going through some pretty nifty stuff such as RESTful geospatial applications development. Hope to see you there!

rotation in postgis

It appears the rotate function in PostGIS only rotates the geometry about the center of the co-ordinate systems. There was a neat little trick that was mentioned on the postgis-list by Bruce Rindhal to rotate a polygon about its center:

CREATE TABLE shapes (gid serial PRIMARY KEY,  name varchar);
SELECT AddGeometryColumn('', 'shapes', 'the_geom', -1, 'POLYGON', 2);
insert into "shapes" ("the_geom", "name") values (
       'POLYGON((2 2, 2 7, 12 7, 12 2, 2 2))', 'laying down');

Next we are going to translate the polygon’s centroid to (0,0). Rotate it by 45 degrees and then move it back to the original centroid.

SELECT
translate(
  rotate(
    translate( the_geom, -x(centroid(the_geom)), -y(centroid(the_geom)) ),
    radians(45)
  ),
  x(centroid(the_geom)), y(centroid(the_geom))
)
from shapes where name = 'laying down';

postgis rotation
Without the translate on line 4 and line 2 and 7 it would look like this:
postgis rotation without translate

Pakistan Wetlands and Ramsar listed sites

Ramsar Sites in Pakistan Page
Wetlands are regarded by nature conservationist as unique ecosystems. They often exhibit delicately balanced environmental conditions and support a wide range of exotic plant and animal species. Wetlands are also often protected by various environmental laws and conventions. Last year when I was visiting Pakistan I learned about the Pakistan Wetlands Project that is under way. The aim of the project is to build capacity for improved wetlands management at the Federal, Provincial and Local government level, as well as the private sector in Pakistan. I thought it would be nice to be able to see all 19 wetlands in Pakistan that are listed under the Ramsar convention on GoogleMaps. This site was built using RubyonRails + GeoRuby. http://pakistan-wetlands.dyndns.org/.  Many thanks to Guilhem for his help during trouble shooting.

postgis template database

Some might find this useful for creating PostGIS databases without having to be postgresql superusers. The idea is to create a template_postgis database, install plpgsql and postgis into it, and then use this database as a template when creating new PostGIS databases.

Now non-superuser’s can create postgis db’s using template_postgis:

createdb -h host-name my_gisdb -W -T template_postgis

PostGIS & Oracle Spatial Price Comparison

Ken Lord emailing to the annual “Who’s using PostGIS and for What?” inquiry wrote in detail about his experienes with Oracle and also a justification for decision to chose PostGIS over Oracle Spatial. I thought it was quite insightfull for anyone who are doing a cost/benefit analysis of choosing a spatial database for their next commercial project. To summarize it costs CAN$60,000 to use Oracle Spatial per CPU for web applications. Support & Maintainance is an additional CAN$13,000.
This is because inorder to use Oracle Spatial you need to buy Oracle Enterprise. Plus if you are going to use it for Web Applications then you will have to pay the per CPU license instead of the per user license.

PostGIS on the other hand seamlessly works with Mapserver (webifying your Spatial DB) and has most if not all of the functions offered by Oracle Spatial. Not to mention the supportive community who contribute by submitting bug fixes and answering newbie to advance questions. The documentation for PostGIS is also quite extensive.

There have been a few interesting comments to the annual inquiry from the developers of PostGIS. One of my favourites was: “We can have a new feature added to PostGIS for the license fees of a commercial solution

This is not to say that one would never consider Oracle Spatial for a project, since Oracle Enterprise with its myriad of features maybe able to fullfill the requirements of a project better than PostgreSQL/PostGIS. However, as far as Spatial Databases are concerned PostGIS does make economic sense.