Trying to build the frame work for a geoTiff Gtk2 app. so far it loads a pre-defined geoTiff(or Tiff) prints the meta-data and captures a mouse click. On the todo list is to have:
1. On mouse click an icon is placed at that position on the tiff. I'm going to guess this has to do with a drawing area but which one? How should it be packed?
2. Convert the window coords from the above mouse click into lat and long of the actual image projection. What governs the $event->x call? I cant seem to find it. Is the geoTiff data printing the whole data?

As always, thanks for the Help.

Here is the code I have so far. To test you would need libgeotiff, a geoTiff and the Image::ExifTool module:
#!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 -init; use Image::ExifTool; use Geo::Coordinates::UTM; #geoTiff File (static) my $filename = 'q3639_DRG24k-c.tif'; #geostats my $ellipsoid = 23; #static WSG83 my $zone; my @mtp; my @ps; my @cs; #Create Window my $window = new Gtk2::Window ( "toplevel" ); $window->signal_connect ("delete_event", sub { Gtk2->main_quit; }); $window->set_border_width (10); $window->set_size_request(640,480); $window->set_position('center'); #create Table my $table = Gtk2::Table->new(1, 1, FALSE); #Create Scrolled Window my $scwin = Gtk2::ScrolledWindow->new(); $scwin->set_policy('always','always'); #Create Viewport my $vp = Gtk2::Viewport->new (undef,undef); #add GeoTiff my $exifTool = new Image::ExifTool; my $info = $exifTool->ImageInfo($filename); foreach (sort keys %$info) { print "$_ => $$info{$_}\n"; #Find the right keys(data) if ($_ eq "ModelTiePoint"){ @mtp = split(/ /,$$info{$_}); } if ($_ eq "PixelScale"){ @ps = split(/ /,$$info{$_}); } if ($_ eq "ProjectedCSType"){ @cs = split(/ /,$$info{$_}); $zone = $cs[3]; } } my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file ($filename); my $widget = Gtk2::Image->new_from_pixbuf ($pixbuf); #Create Eventbox and Pack mouse signal my $ebox = Gtk2::EventBox->new; $ebox->set_events( 'button_press_mask' ); $ebox->signal_connect( button_press_event => sub { my ($widget, $event) = @_; my ($x, $y) = ($event->x, $event->y); #convert UTM to Lat and Long my $easting = $ps[0] * $x + 0.0 * $y + $mtp[3]; my $northing = (-$ps[1]) * $y + 0.0 * $x + $mtp[4]; my ($latitude,$longitude)=utm_to_latlon($ellipsoid,$zone,$easting, +$northing); print "$x, $y, ($latitude, $longitude)\n"; }); #Pack $ebox->add($widget); $vp->add($ebox); $window->add($table); $scwin->add($vp); $table->attach_defaults($scwin, 0, 1, 0, 1); #change the cursor over image $ebox->realize; $ebox->window->set_cursor(Gtk2::Gdk::Cursor->new ('hand2')); $window->show_all; Gtk2->main;

Update1: It seems to get the correct lat and long you can use Geo::Coordinates::UTM but I need the northing and easting of the image.
Update2: I found out that the output loop given before does not give all of the data so I changed it, The new script is above. So far this script is very static and seems to grab the correct coordinates using a formula from the .tfw file. This still leaves the drawing part open. I could use some help on that.

In reply to geoTiff Application Building by deadpickle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.