[Gdal-dev] Convert PNG map / Mercator -> equirectangular projection
Andreas Weller
weller at andreas-weller.de
Fri Aug 31 15:07:39 EDT 2007
Hi!
I used the attached Perl script for grabbing maps from
http://maps.google.com
The tiles are automatically stitched together to one big file -> now
I've got a 12000x12000 px PNG file :-)
I wish to use it with Xastir - an amateur radio mapping program.
Google Maps seems to use mercator projection - for working
correctly the file to needs to match equirectangular projection, also
called the equidistant cylindrical projection.
Any hint how to do it? I think gdalwarp might do it but I don't know how...
Thank you!
Regards,
Andreas Weller, DF1PAW
Here the Perl file:
#!/usr/bin/perl
# download a bunch of google map tiles and stitch them together
# Shifty Death Effect Done by Noah Vawter in May, 2005.
# Computing Culture Groop, MIT Media Lab.
# Modified for compatibility with maps.7.js -> Mmaps.10.js by Ian (June
2005)
# Modified for currently URL format used by google
# and PNG support (instead GIF) by Andreas Weller, DF1PAW (Aug. 2007)
# with width 12
$sx = 2137;$sy = 1375; # DF1PAW home
$w=10; # Width
$h=10; # Hight
open(PEDG,">pedg.html");
for($yd=0;$yd<$h;$yd++)
{
for($xd=0;$xd<$w;$xd++)
{
$x=int($sx+$xd-$w/2);
$y=int($sy+$yd-$h/2);
$localnem = "tile$x,$y.png";
# do we already have it locally?
$val = open(CHECK,$localnem);
if($val == 0){
# http://mt.google.com/mt?v=w2.4&x=4190&y=6012&zoom=3
# 523 wget "http://mt.google.com/mt?v=.38&x=5376&y=-730&zoom=2"
# have a look at the Url and modify these lines:
$req="http://mt.google.com/";
$nem="mt?v=w2.60&x=$x&y=$y&zoom=5";
$url = $req . $nem;
print "$url\n";
$cmd1="wget \"$url\" ";
print "$cmd1\n";
system($cmd1);
# $nem =~ s/\?/@/;
$cmd2="mv \"$nem\" $localnem";
print "$cmd2\n";
system($cmd2);
}
print PEDG "<img src=$localnem>\n";
}
}
# concatenate horizontal maps
# convert tile005000.png -page +129+0 tile006000.png -page +258+0
tile007000.png -mosaic o.png
for($yd=0;$yd<$h;$yd++)
{
$cmd3 = "convert ";
for($xd=0;$xd<$w;$xd++)
{
$x=int($sx+$xd-$w/2);
$y=int($sy+$yd-$h/2);
$localnem = "tile$x,$y.png";
$xsh = $xd*128;
$ysh = $yd*128;
$cmd3 .= "$localnem ";
}
$cmd3 .= "+append tmp$yd.png";
print "$cmd3\n";
system($cmd3);
}
# concatenate horizontal strips
$cmd4 = "convert ";
for($yd=0;$yd<$h;$yd++)
{
$localnem = "tmp$yd.png";
$cmd4 .= "$localnem ";
}
$cmd4 .= "-append output.png";
print "$cmd4\n";
system($cmd4);
More information about the Gdal-dev
mailing list