deadpickle has asked for the wisdom of the Perl Monks concerning the following question:

I'm looking to build an interface using GTK2 and GeoTiff images. I have been directed to libgeotiff library and was wondering if there is a perl module to handle this. Also, I found the module Image::ExifTool, but I'm not sure it is capable of displaying geotiffs. I'm really just wondering what is known about doing this in perl so any references would be appreciated.

Replies are listed 'Best First'.
Re: Geotiffs and GTK2
by Joost (Canon) on May 15, 2008 at 20:39 UTC
    AFAIK GeoTiffs are just regular TIFFs with additional data about coordinates and projection. In other words, any tool that can display TIFFs can display GeoTIFFs. It only gets interesting when you want to do something with the geo metadata. I've used gdalinfo to get at the metadata to stitch together bundles of GeoTIFFs using image-magick & GD. If you need to convert to different projections you may need something more specialized. update: see also the rest of the GDAL site for command line tools that handle and convert all kinds of geospatial file formats.

      is gdal coded in C? if it is how do you interpret it into perl? I have found a module called Geo-GDAL but it is still a beta version but it might be useful.
        GDAL is coded in C (or maybe C++, I'm not sure). What I meant was I just used the output of the command line program gdalinfo to get at the coordinates (using the `` operator).

        Doing that means incurring some overhead, but since you can cache the results you really only have to do /whatever you need to do/ once per image, so usually you don't care*.

        Besides, if you need to, it's probably relatively easy to write XS extensions using the GDAL library. I just didn't have to. I wrote some pretty extensive interfaces to geos though.

        * or at least, not if you've got about two hundred images, all about 10Mb+ in size. The overhead of starting a separate process and filtering its output will be dwarfed by the disk IO.

Re: Geotiffs and GTK2
by mr_mischief (Monsignor) on May 15, 2008 at 17:25 UTC
    Image::ExifTool will deal with the meta info for GeoTiff (by loading Image::ExifTool::GeoTiff), but it's meant only for meta info and not to display the images.

    Searching CPAN for "GeofTiff" doesn't turn up anything about displaying them, but as I understand it GeoTiff images are essentially TIFF6 with some extensions, most of which are meta info extensions. I'm not sure how well regular TIFF software will deal with any of that.

    There is a full spec, API reference, and source code for libgeotiff at http://www.remotesensing.org/geotiff/geotiff.html which may help you implement something to deal with the format.

Re: Geotiffs and GTK2
by zentara (Cardinal) on May 16, 2008 at 15:00 UTC
    The way Gtk2's graphics subsystem is setup, a c lib, like libgeotiff, will make itself available to the pixbufloader. So once you install it, the format should be available for display. Getting the meta-data out may take an additional step. Maybe ask on the Perl/Gtk2 maillist.
    #!/usr/bin/perl use strict; use warnings; use Gtk2; my @formats = Gtk2::Gdk::Pixbuf->get_formats(); my @exts; foreach my $format ( @formats ) { foreach my $key ( keys( %$format ) ) { next unless $key eq 'extensions'; foreach my $elem ( @{ $format->{ $key } } ) { push @exts, $elem; } } } print "@exts\n";
    or
    #!/usr/bin/perl use strict; use warnings; use YAML; use Gtk2; my (@formats) = Gtk2::Gdk::Pixbuf->get_formats; print Dump([\@formats]);

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
Re: Geotiffs and GTK2
by Anonymous Monk on May 15, 2008 at 17:32 UTC
Re: Geotiffs and GTK2
by hda (Chaplain) on Oct 07, 2008 at 11:35 UTC
    Hi,

    I hope this answer is not too late. For sure you should try the Geo::GDAL module, it works fine. Lately I had some trouble compiling it (on openSUSE 11.0 64 bit, perl 5.10 and GDAL 1.5.2) but in general it does what it is expected to do. I certainly recommend it.

    In any case check the documentation at: http://map.hut.fi/doc/Geo-GDAL/html/

    or joint the GeoPerl mailing list: https://list.hut.fi/mailman/listinfo/geo-perl

    The creator of Geo::GDAL has also done some interesting applications with GTK, although I can't find the webpage now.

    Good luck!