[Xastir] More on radar problem

Jeremy McDermond mcdermj at xenotropic.com
Sun Dec 6 23:56:47 EST 2009


Thanks a lot for this technique Alex.  I've gotten some weather radar on my Xastir maps now.

On Dec 6, 2009, at 10:16 PM, Alex Carver wrote:

> The TIEPOINT directives will assign a specific pixel coordinate (X,Y) to a specific lat/long.  Pixel 0,0 is upper left, and 620x620 is the lower right most pixel on my RIDGE image (the image itself is also 620x620 in this case).  You need two TIEPOINTs so that Xastir can appropriately place the image.  The IMAGESIZE tells Xastir how big the radar file is in pixels (again 620x620 for the Atlanta RIDGE).
> 
> After that, just fix the URL accordingly.
> 
> The more accurate the points, the better the radar will line up with your maps.  I used Delorme Street Atlas to find a couple known points in the RIDGE data and then worked my way back to the corners.  You don't have to use the corners of the image file, any two points will do since Xastir knows about the overall image size using the IMAGESIZE directive.

Note that if you get the same file with a .gfw extension, you'll get some information on the radar map that is returned.  This includes the coordinates for the upper left corner (0,0) and the number of map units per pixel.  If you take these statistics, and multiply them by the resolution of the map (600x550), you can calculate the lower right corner of the map.  So, for example, for the NYC map (OKX), http://radar.weather.gov/ridge/RadarImg/N0R/OKX_N0R_0.gfw will return:

0.00951144131747161
0.000000
0.000000
-0.00951144131747161
-75.7126750876687
43.4768917707963

I wrote a perl script that will take as a single argument the abbreviation of the radar station off of the NWS site, and output to STDOUT a .geo file that should be correct for it.  Note that you'll need to install LWP::UserAgent and Image::Size off of CPAN to make it work. Hopefully folks find this useful.  If someone wants to brush it up and put it into contrib or something, they have my permission.

---------- CLIP ------------

#!/usr/bin/perl

use strict;
use LWP::UserAgent;
use Image::Size;

my $station = uc($ARGV[0]);

my $gif_url = 'http://radar.weather.gov/ridge/RadarImg/N0R/' . $station . '_N0R_0.gif';

my $response = LWP::UserAgent->new->request(
  HTTP::Request->new( GET => $gif_url )
);

unless($response->is_success) {
  die "Couldn't get radar image: ", $response->status_line, "\n";
}

my ($img_x, $img_y) = imgsize(\$response->content);

my $response = LWP::UserAgent->new->request(
  HTTP::Request->new( GET => 'http://radar.weather.gov/ridge/RadarImg/N0R/' . $station . '_N0R_0.gfw' )
);

unless($response->is_success) {
  die "Couldn't get radar descriptor: ", $response->status_line, "\n";
}

my ( $yscale, undef, undef, $xscale, $lon, $lat ) = split(/\r\n/, $response->content);

my $tiepoint_lat = $lat - ($yscale * $img_y);
my $tiepoint_lon = $lon - ($xscale * $img_x);

print "URL\t\t$gif_url\n";
print "TIEPOINT\t0\t0\t$lon\t$lat\n";
print "TIEPOINT\t$img_x\t$img_y\t$tiepoint_lon\t$tiepoint_lat\n";
print "IMAGESIZE\t$img_x\t$img_y\n";
print "REFRESH\t\t60\n";
print "TRANSPARENT\t0x0\n";
print "PROJECTION\tLatLon\n";

--------- CLIP -----------

--
Jeremy McDermond (NH6Z)
Xenotropic Systems
mcdermj at xenotropic.com






More information about the Xastir mailing list