[Gdal-dev] Help a stupid GIS newbie: gdalwarp for GPSDrive maps

S Clark smc+gdal at dogphilosophy.net
Fri Sep 10 22:19:51 EDT 2004


No, 'fraid not.  I was referring to the "map_koord.txt" file that
goes with GPSDrive and contains 4 fields per line:
(filename) (center latitude) (center longitude) ("scale")

for every map image file that GPSDrive is to try to use.
That's, effectively, about all of the information I have for
most of these images (other than the projection type of the source [usually
UTM] and target [geographic/equirectangular/whatever, or miller(?)] images,
and the fact that the image is always 1280x1024 pixels).

If it helps, here's what I'm attempting so far:

/usr/bin/gdalwarp -s_srs '+proj=utm +zone=12 +datum=WGS84 +k=0.9996' -t_srs 
'+proj=eqc +lat_ts=42.94584 +lon_0=-113.2167 +datum=WGS84' 
map_42.94584_-113.2167_5512.jpeg top_kings_bowl.jpg
ERROR 1: Unable to compute a transformation between pixel/line
and georeferenced coordinates for map_42.94584_-113.2167_5512.jpeg.
There is no affine transformation and no GCPs.

Obviously, there's information missing that I need to supply to 
gdalwarp, but I'm neither sure exactly what information, nor how
it's labeled in the *_srs fields...
(The example above is a Terraserver aerial photo of the "King's Bowl" 
crater in southeastern Idaho, near American Falls.  The filename
containing coordinates and scale is just a convention I've adopted
to make remembering what they are easier, and doesn't matter to
GPSDrive.)

If it helps, I DON'T intend to change the map "scale", merely to warp 
the image to match either geographic/equirectangular/plate caree or
"whatever expedia is, possibly Miller" projection.

Getting the X and Y coordinates of the ORIGINAL (non-geographic) image's
upper-left corner seems to be a sticking point - I gather that's not
a straightforward proposition for most projections.  On the other hand, 
calculating the upper-left X and Y for the "target" geographic-projection
image is trivial.  If I can supply that for the target, will gdalwarp
be able to back-calculate the the coordinates for the original
(usually UTM) source image was, given that the scale doesn't change?

For calculating the parameters of what I've been calling the "equirectangular"
image ("top_*" in GPSDrive), here a snippet of the code I've been using
successfully:
-----------------------------------
$degpixel = floatval($scale/313687320); 
//degrees/pixel for equirectangular map (calc'd from GPSDrive code)
$lat=floatval($lat);
$lon=floatval($lon);
$ullon=$lon-($degpixel*640);  //upper-left longitude boundary
$ullat=$lat+($degpixel*512);  //upper-left latitude boundary
$lrlon=$lon+($degpixel*640);  //lower-right longitude boundary
$lrlat=$lat-($degpixel*512);  //lower-right latitude boundary
-----------------------------------

Thanks (yet again),

Sean

On Friday 10 September 2004 07:43 pm, you wrote:
> Sean -
>
> Is that "supplementary text file" an ESRI-format world file?  If so, it
> would be a text file with six lines in it, each of which contains a
> number - and the second and third lines are almost certainly 0.0.
>
> If that's the case, then the first and fourth lines will contain the X
> pixel size and the Y pixel size, in units of degrees.  The fifth and
> sixth lines are the X and Y coordinates of the upper-left corner of the
> image (also in degrees).  Does that look right?
>
>  - Ed



More information about the Gdal-dev mailing list