Programming starts from a data level

The autumn has arrived and it’s again a time to give annual geospatial programming course at Aalto university. This time, actually as always, we start our course from the bottom level moving to the top (user interfaces) . In any application development it’s important to know what happens behind the scenes. After knowing the principles you can start to implement nice looking user interfaces and functionalities.

We will first look into databases with geospatial extensions to enable functions and procedures like overlaps, intersects, buffer and union. There are many database software available for this kind of functionality. In our case we will use software from OSGeo, namely Spatialite and PostGIS, but obviously you may use commercial stuff like Oracle Spatial or MS SQL Server as well. Both OSGeo databases can be run immediately from excellent OSGeo Live Dvd, which is a virtual machine (Linux Ubuntu) and can be run from a memory stick, DVD or a local hard drive.

Software we are using are based on open standards from OGC (Open Geospatial Consortium). These standards, particularly in this case, are SQL related and give us same functionality (read functions) to solve our problems. The first thing we are digging into is WKT (Well Known Text). It is the standard for defining points, lines and polygons in a clear text format.

Here is an example of WKT:

POINT (60.213 21.3181)

As you can see, it is very simple and understandable. First you define a type of your object and then pairs of coordinates, finally with optional coordinate system.

Even if the data is stored in a database e.g in BLOBs (Binary Large OBjects) it is sometimes nice to see the content in more understandable format. Next we will do some analysis such as looking which are the neighborous of our area of interest (like a municipality) and how many sq km’s the object actually is.

Here is a simple example of creating a buffer

ST_GeomFromText(‘POINT(100 90)’), 50)

These are some basics on data(base) level to start geospatial programming. There are many others such as understanding coordinate systems, but this out of scope from my point of view as I’m teaching “programming”, not coordinate systems

The next session and from that onwards we will concentrate on different programming libraries like Geoscript, Geotools and finally jumping into Openlayers to develop web applications, not to forget web servers and e.g Geoserver to reveal content via WMS and WFS.

Written and posted from Almería, Spain.