Monday, December 6, 2010

Export a GeoMedia Access Warehouse to Postgis with GM2PGSQL

If you have been using Postgis for a while, you would be familiar with the shp2pgsql executable. This executable converts a shapefile into a Postgis SQL file for bulk loading into a Postgis database. There is a similar executable for converting a GeoMedia Access warehouse into Postgis. It is gm2pgsql, a free executable which is downloadable from this web site http://gm2pgsql.projects.postgresql.org/.

To use this executable,
  1. Type in the gm2pgsql command at the Windows Command Prompt.

    For example, input.mdb is the source GeoMedia Access warehouse, output.sql is the destination Postgis SQL file, pgdatabase is the destination Postgis database schema name, and -1 is the SRID number.

    C:\> gm2pgsql input.mdb output.sql pgdatabase -1
  2. Press RETURN.

    All the supported features in the Access warehouse are exported out.
If you open up the resultant SQL file with Notepad, the SQL statements to create the corresponding Postgis tables and corresponding feature attributes and geometries can be seen, as shown below. 
It seems that there is no way to limit the export to a single feature table; it will export all features that it recognizes. For more details, please visit the gm2pgsql project page at http://gm2pgsql.projects.postgresql.org/.

No comments: