Tag Archive for 'PostGIS'

Happy new year!

Since I quit smoking last year there are no personal resolutions left for 2006. I’ll give them another try in 2007, earliest, quitting smoking usually gives you bonus resolutions for at least 5 years. But I do have some wishes I would like to see come true in 2006. So listen up politicians and product managers, here we go:

  • World peace
  • Fair policies and fair distribution of goods for developing countries
  • Ongoing implementation of the Kyoto Protocol
  • ArcGIS 9.2 with built-in PostGIS/PostgreSQL and GML support: small businesses like us badly need a cost-efficient Spatial-DBMS solution!
  • GPS enabled iPod nano: this gadget has perfect (not to say divine) dimensions and now I would like to see an arrow on its display which routes me to an address out of my address book, further I would appreciate the possibility to save my current location and load it later into tools like Google Earth or automatically add the positions to my photos in iPhoto (there is already an EXIF placeholder for coordinates in the image property window!) by syncing time stamps of photos and gps tracks for instance
  • a working INSPIRE service: EEA’s data service and UNEP’s Geo Data Portal are working very well but I would like to see a service similar to Mapdex for EU-specific datasets and some more webservices up and running.
  • to be completed…

Finally!

PostGIS 1.0.0 Released!!!

After a long series of release candidates, the much anticipated 1.0.0 version of PostGIS has been released. The 1.0.0 version includes substantial changes over the original 0.X series, most importantly a new on-disk format which is both more compact and faster to access. The 1.0.0 version is compatible with PostgreSQL 7.2 and higher, but is most tighhtly integrated with the PostgreSQL 8.0 and higher releases.

New features in 1.0.0 include:

* Smaller and faster on-disk formats
* Improved selectivity estimates, including support for join selectivity and sub-selects
* Hex-based canonical format, for driftless dump and restore
* 4-D geometries
* New functions:
o Polygonize
o AsGML
o ForceRHR
o SnapToGrid
o Geometry Constructors
* Improved JDBC interface with jdbc2 support
* 64-bit platform support
* Performance improvements for common boolean operators

My plan now is to test the acceptance of an (company) internal information system, just to optimize the workflow between GIS-workers (like me) and other colleagues that always need some temporary maps or (fast) geographic information in general. The problem is that our results are usually the product of a discussion between the GIS-worker (knowing and explaining the possibilities of GIS) and the client (explaining the problem and objectives). I’m not sure if my colleagues are willing to learn some basic features of GIS to finally use a simple GIS by themselves. A first approach was the use of ArcGIS Publisher, with the result that the one colleague working with ArcReader and my published data is really excited about it. He don’t has to show up every time he needs minor changes like another view, scale or combination of certain layers. And of course it saves a lot of my time as well.

Anyhow, ArcGIS Publisher is one option. Another one will be a browser-based information system with the advantage, compared to ArcGIS Publisher, of centralised data management. To accomplish this test with ESRI-software we would have to license additionally at least ArcEditor, ArcSDE and ArcIMS. Since we’re not focused on IT-projects that costs would be pretty heavy for our internal software budget. Thus I thought I’ll give it try using open source software (and of course because I know it works quite well) – PostGIS/PostgreSQL as backend, UMN mapserver or deegree as middleware and a nice browser interface as frontend. Let’s see when I find time to set something up…

Besides the idea of that internal information system, I’m thinking about using PostGIS as “drudge” to swap out intensive geoprocessing tasks. Performing those tasks on my ArcGIS workstation means spare time for me because it’s getting so busy that I’m not able to do anything else but waiting until the process is done.

PD: I really would suggest some open source sceptical companies to have a look at this great piece of software – it’s not evil, it’s just competition ;-)

PostGIS & ArcGIS

Another interesting message about using PostGIS as backend to commercial GIS-clients like ESRIs ArcGIS has been submitted to the PostGIS-mailing list:

“The PostgreSQL OLEDB Provider does not support rowsets, which ArcGIS and other commercial software look for in a data source. That’s why you can establish a connection, but it will always look empty to ArcGIS, regardless of whether you’re trying to load spatial or non-spatial data.
I am just about to finish an extension to ArcMap that loads spatial and non-spatial data from PostGIS and PostgreSQL (as well as other databases) into ArcMap. It does not use a live OLEDB connection, but caches data in local scratch workspaces (personal geodatabase, i.e., Microsoft Jet format).”

[postgis-users] RE: ole db, arccatalog and arcmap

PostGIS, ESRI & Windows

PostGIS 0.9.0 released

Beside various new features (e.g. GEOS 2.0) PostGIS now comes along with Klaus Försters AsSVG() functionality, which allows to deliver SVG elements directly out of PostGIS.

ESRI & PostGIS

ESRI released their ArcGIS Data Interoperability Extension, which finally offers a slightly integration of PostGIS into their products. A first review and user experience you can find here.

Windows & PostGIS

For testing PostgreSQL/PostGIS on windows without cygwin I recommend to check out those installers:
PostgreSQL Win32-Installer
PostGIS Win32-Installer
PostgreSQL/PostGIS Win32-Installer
PostgreSQL/PostGIS on Windows Tutorial

Developing the Road Accident Information System

PostgreSQL/PostGIS under Win32

If you are interested in trying PostGIS under Windows, I suggest you follow that thread in the PostGIS-Users mailing list. A Win32 PostgreSQL 7.5/PostGIS snapshot is available for developers.

Das Anwendungsbeispiel

Während der Beschreibung der Funktionen des praktischen Beispiels kamen mir einige Ideen wie einzelne Features eventuell verbessert werden könnten. Ein paar Tests in diese Richtung gaben mir recht und das Beispiel wurde weitgehend adaptiert.

So, nach 2400 Zeilen Sourcecode ist der stabile Punkt, wo ich das Beispiel ruhen lassen kann, endgültig erreicht und mein eigener Ehrgeiz, eine funktionelle kartographische Applikation zu entwickeln, gestillt.

Highlights

- Automatisierte und maßstabsabhängige Generalisierung der Straßen und Bezirke
- Suche und Anzeige von Detailinformationen einzelner Kartenelemente (z.B. Nachbarschaftsfunktion bei Bezirken, Überlappungen bei Bezirken und Straßen)
- Plattformunabhängig und (theoretisch) skalierbar auf jede Bildschirmgröße durch ausschließlicher Verwendung der ASV-Script-Engine und ASV-DOM
- Bei Verwendung von PostgreSQL/PostGIS als Backend in GIS-Systemen könnte diese Anwendung das Web-Frontend bilden, die laufend und ohne zusätzliche Arbeitsschritte die aktuellen Daten visualisiert.

Eine Demonstration des Beispiels ist hier zu finden. Jedoch ist die Datenbank nicht online und daher sind einige Funktionen deaktiviert.

Das Anwendungsbeispiel

Im Herbst 2004 kam ein Update des von mir eingesetzten Datenbankservers PostgreSQL auf die Version 7.4 sowie des PostGIS-Moduls auf die Version 0.8.0 (inzwischen 0.8.1) heraus.
Die Aktualisierungen waren etwas trickreich, erweiterten jedoch mein Beispiel um essentielle Funktionen. Mit Hilfe von GEOS werden nun alle räumlichen Funktionen der OpenGIS “Simple Features for SQL” Spezifikation unterstützt.Als Beispiel möchte ich an dieser Stelle nur die Methode simplify erwähnen, die auf Basis des Douglas-Peuker Algorythmus eine automatisierte Generalisierung der Geodaten durchführt. Simplify führte in meinem Beispiel zu einer wesentlichen Steigerung der Darstellungsgeschwindigkeit bei gleichzeitiger Erhaltung der originalen Geo(GIS)daten, was eines meiner Ziele bei der Entwicklung des Beispiels war.

Die automatisierte Generalisierung von Geodaten ist im Allgemeinen ein sehr heikles Anwendungsgebiet. In meinem Beispiel ist jedoch die Ausgabegenauigkeit (“slivering polygons”) durchaus ausreichend und v.a. in Verbindung mit dem Perfomancegewinn als deutliche Verbesserung zu sehen.

Interessantes rund um Webmapping und GIS

Mein im September angetretener Job beansprucht zwar einerseits viel Zeit, die ich eher für die Fertigstellung der Diplomarbeit gebrauchen könnte, andereseits eröffnet er mir auch Zugang zu sehr interessanten Themenbereichen die hoffentlich auch in der Diplomarbeit berücksichtigt werden können.

PostGIS in Verbindung mit ESRI ArcGIS

IMSEMU: Ein (Perl) Layer der auf dem Mapserver (künftig auch auf PostGIS) einen ArcIMS Map Server simuliert und somit von ArcGIS-Clients genutzt werden kann.
PgArc: Extension für ArcGIS die es ermöglicht PostGIS als Geodatenserver zu nutzen.
OGC Interoperability Add-On: Extension für ArcGIS 8.3 um auf OpenGIS Web Map Services (WMS) und Web Feature Services (WFS) zugreifen zu können. Auch wird mit dieser Extension GML (Geography Markup Language) als Exportformat für Geodaten angeboten.
Der nächste Release von ArcGIS (Version 9) unterstützt u.a. die Open Source Programmiersprache Python und läßt daher auf weitere interessanten Entwicklungen v.a. in der Open Source Welt hoffen.

Webmapping

Mapbender: Auf der CORP 2004 hatte ich die Möglichkeit eine Präsentation der Firma CCGIS zu sehen, die die Open Source Software Mapbender entwickelte. Mapbender ist ein Web basiertes, mit PHP umgesetztes GIS Front End zur Bedienung von OGC-konformen WMS (Web Map Service). Mapbender (u.a. in Verbindung mit PostGIS) bestach auch bei verteilter Datenhaltung durch sehr hohe Performance.
deegree: Mit maßgeblicher Unterstützung der Firma lat/lon entwickelte Open Source Web (Map) Services Suite.

Installing PostGIS 0.8.0 on Mac OS 10.3.2

PostGIS runs on top of the PostgreSQL and adds support for geographic objects to the object-relational database.

Installing the latest PostGIS Release on Mac OS 10.3.2 can be tricky, so I summed up the main steps I did to get PostGIS up and running on my machine.

Since my unix knowledge is very limited I have to thank the PostGIS Listers, Rich Kilmer, Entropy.ch and Nona.net for their very helpful hints.Basically you need to follow those 6 steps:

- Install GNU GCC 3.4
- Install Readline 4.3 (for readline support in PostgreSQL)
- Install PostgreSQL 7.4
- Install PROJ.4
- Install GEOS 1.0.0
- Install PostGIS 0.8.0

Install GNU GCC 3.4

Download the sources from one of the mirrors.
Read the installation instructions twice.
Configure and install GCC 3.4.

/usr/local/src user$ tar -xf gcc-3.4-20031217.tar
/usr/local/src user$ cd gcc-3.4-20031217
/usr/local/src user$ mkdir /usr/local/gcc-3.4
/usr/local/src user$ cd /usr/local/gcc-3.4
/usr/local/gcc-3.4 user$ /usr/local/src/gcc-3.4-20031217/configure --prefix=/usr/local/gcc-3.4 --enable-shared=libstdc++ --enable-languages=c++
/usr/local/gcc-3.4 user$ make
/usr/local/gcc-3.4 user$ sudo make install
[enter the su password]

After GCC 3.4 is built you have to modify the file /usr/include/mach-o/dyld.h:

add the line
#define __private_extern__ extern
just above the block
#if defined(__MWERKS__) && !defined(__private_extern__)
#define __private_extern__ __declspec(private_extern)
#endif

To use GCC 3.4 I backed up the Apple original GCC binaries in /usr/bin and created symlinks (ln -s) from the binaries in /usr/local/gcc-3.4/bin to /usr/bin. Maybe there is an easier way to switch between GCC versions (e.g. by editing gcc_select), but my way did the trick too.

Install Readline 4.3

/usr/local/src user$ curl -o readline-4.3.tar.gz ftp://ftp.gnu.org/gnu/readline/readline-4.3.tar.gz
/usr/local/src user$ tar -xzf readline-4.3.tar.gz
/usr/local/src user$ cd readline-4.3
/usr/local/src/readline-4.3 user$ perl -i.bak -p -e "s/SHLIB_LIBS=.*/SHLIB_LIBS='-lSystem -lncurses -lcc_dynamic'/g" support/shobj-conf
/usr/local/src/readline-4.3 user$ ./configure
/usr/local/src/readline-4.3 user$ make
/usr/local/src/readline-4.3 user$ sudo make install
[enter the su password]

Install PostgreSQL 7.4

Download the sources from one of the mirrors.
Read the documentation.
Configure and install PostgreSQL.

/usr/local/src user$ tar -xzf postgresql-7.4.tar.gz
/usr/local/src user$ cd postgresql-7.4
/usr/local/src/postgresql-7.4 user$ LDFLAGS=-lstdc++ ./configure --bindir=/usr/local/bin --mandir=/usr/local/share/man/ --enable-recode --with-CXX --enable-odbc --enable-syslog --enable-unicode-conversion --enable-multibyte

[Note: this is my configuration, important is not to forget to set LDFLAGS=-lstdc++]

/usr/local/src/postgresql-7.4 user$ make
/usr/local/src/postgresql-7.4 user$ sudo make install
[enter the su password]

Create a new user in the Users System Preferences Pane:
Name: PostgreSQL User
Short Name: postgres
Password: whatever you want

/usr/local/src/postgresql-7.4 user$ sudo chown -R postgres /usr/local/pgsql/
/usr/local/src/postgresql-7.4 user$ su - postgres
[enter the postgres password]
~ postgres$ /usr/local/bin/initdb -D /usr/local/pgsql/data
~ postgres$ usr/local/bin/pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/data/postgres.log
start ~ postgres$ /usr/local/bin/createdb test1
~ postgres$ /usr/local/bin/psql test1

Install PROJ.4

Download the source.
Configure and install PROJ.4.

/usr/local/src user$ tar -xzf proj-4.4.7.tar.gz
/usr/local/src user$ cd proj-4.4.7
/usr/local/src/proj-4.4.7 user$ ./configure
/usr/local/src/proj-4.4.7 user$ make
/usr/local/src/proj-4.4.7 user$ sudo make install
[enter the su password]

Test your installation by running the command:

~ user$ proj

If your installation was successful the output should be something like:

Rel. 4.4.7, 31 March 2003
usage: proj [ -beEfiIlormsStTvVwW [args] ] [ +opts[=arg] ] [ files ]

Install GEOS 1.0.0

Download the source.
Configure and install GEOS.

/usr/local/src user$ tar -xzf geos-1.0.0.tar.gz
/usr/local/src user$ cd geos-1.0.0
/usr/local/src/geos-1.0.0 user$ ./configure
/usr/local/src/geos-1.0.0 user$ make
/usr/local/src/geos-1.0.0 user$ sudo make install
[enter the su password]

Test your installation by running the command:

~ user$ geos-config --libs

If your installation was successful the output should be something like:

-L/usr/local/lib -lgeos

Install PostGIS 0.8.0

Download the source.
Read the documentation.
Put the tar file in the contrib directory of your configured PostgreSQL source tree.

/usr/local/src/postgresql-7.4/contrib user$ tar -xzf postgis-0.8.0.tar.gz
/usr/local/src/postgresql-7.4/contrib user$ cd postgis-0.8.0
/usr/local/src/postgresql-7.4/contrib/postgis-0.8.0 user$ make
/usr/local/src/postgresql-7.4/contrib/postgis-0.8.0 user$ sudo make install
[enter the su password]

Copy postgis.sql and spatial_ref_sys.sql from the postigs-0.8.0 directory to wherever you want, but be sure to remember the location, you’ll need those files later.

Login as postgres and start PostgreSQL:

/usr/local/src/postgresql-7.4 user$ su - postgres
[enter the postgres password]
~ postgres$ usr/local/bin/pg_ctl -D /usr/local/pgsql/data -l /usr/local/pgsql/data/postgres.log start

Create a test database and set up PostGIS support:

~ postgres$ /usr/local/bin/createdb test2
~ postgres$ /usr/local/bin/creatlang plpgsql test2
~ postgres$ /usr/local/bin/psql -d test2 -f postgis.sql
~ postgres$ /usr/local/bin/psql -d test2 -f spatial_ref_sys.sql

Now you should be able to use PostGIS.

Summertime

Nochmalige Umstellung der Datenbank auf PostgreSQL/PostGIS

Nach intensiven Gesprächen mit einem (Unix)Experten und den daraus resultierenden Empfehlungen, kam der Entschluss, die Datenbank noch einmal (und hoffentlich das letzte Mal) zu migrieren.Hauptgründe für diesen Schritt:
- sehr weit fortgeschrittene Implementierung der OpenGIS-Spezifikationen in PostGIS
- sehr zuverlässiger und stabiler Datenbankserver
- Möglichkeit des direkten Imports von ESRI Shape Files in PostGIS
(- Verwendung von PostGIS als Geodatabase in ESRI ArcGIS)

Anpassung der Scripts an den neuen Datenbankserver und dessen Funktionen

Ursprüngliche Schätzung des Zeitaufwandes für die vollständige Migration (eine Woche) entpuppte sich als sehr unrealistisch. Letztlich wurde den ganzen August an der Migration (inkl. weiteren Detailverbesserungen im September) gearbeitet.

Krise

Frage: Ist dieser Aufwand für eine Diplomarbeit berechtigt?

Antwort: Ja. Im Endeffekt arbeite ich für mich und der Lernerfolg während dieser Arbeit gibt mir Recht. In meiner weiteren Laufbahn werde ich wahrscheinlich nur unter sehr günstigen Umständen (großzügige Mitarbeiterschulung seitens des Arbeitgebers) die Möglichkeit haben mich so intensiv mit diesem Thema zu beschäftigen. Ergebnis dieses Arbeitsprozesses ist ein fundiertes und leicht ausbaufähiges Basiswissen in diesem Themenbereich.

Ergebnis

- Elegante und nachhaltige Lösung der Aufgabenstellung
- Erreichung eines bestimmten Grades an Selbstzufriedenheit mit der Arbeit und dem Ergebnis