rdata2img.perl

A perl script using Image::Magick lib.

 

#!/usr/bin/perl
# will plot earthquake location.
# par/assets map-dot-data.
use Image::Magick;

my($image , $q);

$image=Image::Magick->new;
 
$q= $image->Read('world.topo.png');
warn "$q" if "$q";

$q= $image->Read('dot.png');
warn "$q" if "$q";

$imX = $image->[0]->Get('width');
print $imX;
$imY = $image->[0]->Get('height');
print $imY;

print $imX
print $imY; 

#open datafile.
open (data_in, "epic.cgi.txt") || die " could not open file";
#open (data_in, "data.txt") || die " could not open file";

@raw = <data_in>;
foreach $line (@raw)
{

    print $line;
    @sub = split( " ", $line);
    $Long=@sub[6];
    $Lat=@sub[5];
    $Mag=@sub[8];
    $Depth=@sub[7];

    $x = (( $Long/180 ) * ( $imX/2 ))+ ( $imX/2 );
    $y = (-($Lat/90)*($imY/2)) + ($imY/2);
    $x = $x;
    $y = $y;

    print "X = $x\n";
    print "Y = $y\n";
    print "Mag = $Mag\n";   
    print "Depth= $Depth\n";   
    $qorig = $image->[1];
    $q = $qorig;
#    $q->Scale(width=>$10 , height=>10);
#    $q->Modulate(hue=>$Depth%100);

    $montage = $image->[0];
    $montage ->Composite(image=>$q, x=>$x, y=>$y);

}
    $q = $montage->Write(filename=>'/root/Desktop/earth/test.jpg');
    warn "$q" if "$q";
    undef $image;