Page 2 of 3
Previous | Next

Free, cheap, and powerful: PostGIS, the Open Source geodatabase

The document is now the reference for any geodatabase; PostGIS is fully OGC compliant (at the time of writing, formal acceptance from OGC is under way).

POSTGIS AND POSTGRESQL: A BIT OF HISTORY

Back in 2001, the Canadian GIS firm Refractions (Victoria, British Columbia: http://www.refractions.net analysed the geodatabase systems available on the market, and concluded that all were either very expensive, very slow, not expandable and customizable, or some combination of the above. Therefore, they decided to start the development of a new tool. Much in the line of the Open Source strategy, they built on existing blocks, and in particular on the most advanced, powerful and stable Open Source RDBMS available: PostgreSQL (http://www.postgresql.org).

PostgreSQL has very interesting features, paralleled only by the most powerful (and expensive) proprietary systems, among which:
  1. it is fully ACID compliant (guarantees the integrity of transactions);
  2. it supports a wide set of different data types;
  3. allows the management of very large data bases (hundreds of Terabytes), even with computer of limited power;
  4. allows clustering, load balancing, efficient use of multiprocessor computers, and data redundancy;
  5. has strong security, based on several cryptographic modes
  6. it has ODBC and JDBC drivers, so it can be accessed from a variety of clients, even proprietary (like the popular MicroSoft Access).


See http://www.postgresql.org/about/advantages for further details. Starting from current main version (8.x), it is available natively for many different operating systems (Solaris, Linux, HPUX, FreeBSD, and even Microsoft Windows).

This choice was a wise one, and allowed PostGIS to grow rapidly, and to fulfil all the requirements of OGC specifications within a couple of years. The integration with the Java Topology Suite (ported in C++ as GEOS library: (http://geos.refractions.net) allowed the analysis of geographic data directly within the database, without any need for additional, external tools. The integration with the PROJ library (http://proj.maptools.org) allowed the management and conversion of thousands of different projection systems.




Fig. 4
The SPIT plugin in QuantumGIS, allowing the conversion from shapefiles into PostGIS from a graphical interface.





Fig. 5
With the function SELECT TRANSFORM (geometry, SRID) a geometry can be transformed between different projections.


HOW DO I GET IT?

Installation and setup of PostgreSQL+PostGIS is very straightforward on the majority of systems: most Linux distribution have it packaged (thus, it is installable with a couple of clicks, or one simple command). Windows users have a clickable installer available. Of course, being Open Source and Free Software, its download and installation is free, in both senses of not having to pay anything and being free to use and modify the program at your will.

Once installed, the first configuration is easy, but requires the correct understanding of some basic concept (what is a database function, what is the spatial reference system table, etc.). The most advanced Linux distribution (in particular our preferred, Debian GNU/Linux: (http://www.debian.org) do automatically most of the necessary configurations. Once installed and configured, the management of the database can be done, either with a graphic client (see below) or through the native PostgreSQL command line interface.

HOW DO I GET MY DATA IN?

PostGIS allows for seven different geographic data types: POINT, LINESTRING, POLYGON, MULTYPOINT (collection of different point elements), MULTILINESTRING (collection of different linear elements), MULTYPOLYGON (collection of different areal elements), GEOMETRYCOLLECTION (collection of elements of different types: points, lines, polygons).

Each of them can be either two (x,y) or three-dimensional (x,y,z, i.e. fully three-dimensional, not simply draping). Every record has its own Spatial Reference ID (SRID), one code from the spatial_ref_sys table (Fig. 2) , identifying uniquely its projection system; user can therefore mix data from different sources, keeping each in the original projection format, or converting them during the importation process. For migrating large and complex sets of data, it is possible to use directly the Simple Feature (OGC) SQL, but several tools make the life easier:

  1. PostGIS itself comes bundled with its own command line tool (shp2pgsql: from shape to postgis) who converts ESRI shapefiles into the necessary set of SQL commands, to be fed to PostgreSQL
  2. the program (also command-line driven) ogr2ogr, included in the distribution of the library gdal (http://www.gdal.org) is capable of converting between over 20 vector formats (a list at: (http://www.gdal.org/ogr/ogr_formats.html) , including shapefile, ArcInfo, Oracle Spatial, etc.
  3. if you do not like the command line, QGIS (http://qgis.org), an easy-to-use free desktop GIS, has a plugin that allows importation of shapefiles into PostGIS entirely from the graphical interface (Fig.3)
Page 2 of 3
Previous | Next