Wednesday, June 25, 2008

GeoMedia Terrain's Unintuitive Terrain Models Dialog Box

The first time I launched the Terrain Models command, I was dumbfounded for a while. Quite a while. I was supposed to build a terrain model using this dialog but there are no obvious indicators to guide me along. The layout and visual arrangement of the buttons, list boxes and labels do not tell me which item I should click on first.

How was I to know that you have to select a Geomorphic data store or a grid data store label and drag the item and drop it on one of the labels: Grid Terrain model or TIN terrain model? Only after reading the online document Working with GeoMedia Terrain that I learn about how to do it. Intergraph need to redesign this dialog box for better user interaction.

Tuesday, June 24, 2008

GeoMedia and PostGIS

PostGIS is an open source software that spatially enables the PostgreSQL database. I have been using PostGIS for several years and it has served me well personally as well as in a couple of GIS implementation projects. It is easy to use and I really like being able to create spatial tables and perform spatial queries and analysis all from the SQL prompt. I could string a number of the statements into a script for automated batch processing. An example PostGIS spatial query is shown below:

create table demand as
select
a.postcode, a.telno, a.acctclass, a.premisenumber, a.premiseaddress, a.avgbill, a.acctclass, a.x, a.y, a.demandtype, b.polygonid
from custdata a, demandpolygon b
where (a.the_geom && b.the_geom) and
intersects(a.the_geom,b.the_geom)
order by b.polygonid

The field the_geom is the geometry field of the tables; the operator ' &&' is similar to Oracle's first pass rough filter while intersects is a spatial operator.

One of the problems that I face is the lack of a good graphical user interface for viewing and manipulating spatial data in PostGIS. I have to export data in Shape file format using the PostGIS utility pgsql2shp for viewing in GeoMedia.

However, I have just seen the Intergraph 2008 GeoMedia Product Updates presentation and I am pleased to see that a PostGIS Data Server will be developed as part of a minor release of GeoMedia 6.1. It is not known whether it will be a Read only or Read/Write data server. Let's hope it is R/W. Here is a crop of a slide below:

Thursday, June 19, 2008

Firefox 3.0 "Awesome" Bar

The new Mozilla Firefox 3.0 has been newly installed on my work computer and from the word go it is an amazing piece of work. It feels snappier and web pages seem to load and render faster than the previous version 2.0. But the most jarring change is with the url bar (some people call it the Awesome bar or Smart bar). Unlike version 2.0, it comes with a smarter auto-complete algorithm and rich text display (see the figure below); the auto-complete is no longer limited to the first characters of the url.

At first, using the new url bar felt awkward but I can see benefits of using it, so I'm going to keep it. There is a Firefox extension - the OldBar here at https://addons.mozilla.org/en-US/firefox/addon/6227 that you can install if you really don't like the new url bar and prefer how the urls look in the old way.

Wednesday, June 18, 2008

Batch Resize Image Files with ImageMagick

There is a useful open source software for manipulating image files. No, I'm not talking about GIMP but rather another software suite called ImageMagick. ImageMagick can read, convert and write images in a variety of formats including JPEG, PNG and even PDF. It comes with command line utilities like convert, mogrify, identify, composite, etc. The main reason I am mentioning ImageMagick is that I like to use its mogrify utility to resize a large number of image files for display on my Palm Tungsten device. High resolution images cannot be displayed on my PDA due to insufficient memory - so I have to resize the images to a lower resolution. Photoshop has a graphical resize tool but Photoshop is not free and it takes a longer time to fire up. With ImageMagick, all I have to do is open up a Command Window and type in the following commands:

C:\> mogrify -resize 90% *.jpg

The above command will resize all files with the extension JPG to 90% of their original resolutions.

Note: Make copies of your files before using mogrify as it will make the adjustments on the actual files.

Wednesday, June 11, 2008

Contact Me

Do you have a comment, observation or suggestion for me? Just click here and type in your message details

Bulk Update Microsoft Access Database

Introduction

Microsoft Access is one of the easiest to use database application software with a lot of wizards and graphical utilities to guide the users along. For these reasons, I like to use it for prototyping database designs and processing small sets of data. One of the annoyances with Microsoft Access is that the Query tool does not allow me to run bulk SQL statements at one time as shown in the figure below.

This post shows a simple method to perform a bulk update of records in a Microsoft Access database from SQL statements in a text file using Perl and ODBC. I will also provide a link to download the Perl program

Software Prerequisites
  1. Download and install ActiveState Perl.
  2. Download and install the ODBC Driver for Perl DBI.
Notes: To download and install the ODBC Driver, select Start > All Programs > ActiveState Perl 5.x.x Build xxx > Perl Package Manager (see the figure below). Look for the package DBI-ODBC and mark it for install. Finally, run the installation.


Define ODBC Data Source

If you know how to use the ODBC Data Source Administrator to define a data source name, then you can skip this section.
  1. Select Start > Control Panel.
    The Control Panel dialog appears.
  2. Click the following: Performance and Maintenance > Administrative Tools > Data Sources (ODBC).
    The ODBC Data Source Administrator appears.

  3. Click Add.
    The Create New Data Source dialog appears.

  4. Choose Microsoft Access Driver (*.mdb) and click Finish.
    The ODBC Microsoft Access Setup dialog appears.

  5. Type in your Data Source Name and click Select and choose your Microsoft Access database file.
  6. Click OK to close all the dialog boxes.
Create Bulk SQL Text File
You can use any tool or text editor to create your text file containing the bulk SQL statements. An example file is shown below.

UPDATE STORES SET BUILDINGNAME='Post Centre' WHERE ID=34;
UPDATE STORES SET BUILDINGNAME='Empire State Building' WHERE ID=3;
UPDATE STORES SET BUILDINGNAME='Twin Towers' WHERE ID=1;

Using the BulkSQL Program
  1. Download and the BulkSQL.pl program from this link and uncompress the file into a folder of your choice.
  2. Open a Command Prompt window.
  3. At the prompt, type in the following commands to run the program.

    Note: Replace mydatabase with the actual name of your ODBC data source name to your Access database file. Replace mybulksql.txt with the actual name of your bulk SQL text file.

    C:\> perl bulksql.pl mydatabase mybulksql.txt

    A sample run is shown in the figure below.

Notes:
  • The program will print out the number of records affected by a single SQL statement.
  • The program will print out the SQL statement if it did not affect any records.

Monday, June 2, 2008

Brief Initial Look at GeoMedia Terrain 6.1

I have received the GeoMedia Terrain 6.1 CD from Intergraph and promptly installed it on my computer. The product's graphical user interface looks exactly the same as version 6.0 as indicated in the release notes. I connected successfully to my previous terrain warehouses - so far so good. Then I tried the DataStores command and click on some grid and geomorphic data stores - no high level CPU or disk drive crunching activities as happened previously sometimes on version 6.0 - good.

I tried some more commands - Color Coded and Shaded Relief, and Import Grid DataStore and found that Intergraph introduced new bugs. Previously in version 6.0, the Color Coded and Shaded Relief command will save the shaded relief image files to the image data path defined by the terrain options' preference set. Similarly, the Import Grid DataStore command will open the elevation data path by default as defined by the terrain options' preference set. Now, they open up the C:\ path irregardless of what was set in the terrain options.

At first glance, GeoMedia Terrain 6.1 feels more robust and better suited to a production environment. The path problem is a bit irritating but I can live with it.