[Mapserver-users] Raster: rotation params in WLD file

Frank Warmerdam warmerdam at pobox.com
Sat Feb 22 15:15:05 EST 2003


Marian Grigoras wrote:
> Hello Frank,
> 
> 
>>If W[i] is one of lines 0 through 5 of the world file you can calculate
>>the georeferenced location of pixel [Xr,Yr] as:
>>
>>  Xgeo = W[4] + W[0] * Xr + W[2] * Yr
>>  Ygeo = W[5] + W[4] * Xr + W[3] * Yr
> 
> I have to admit I did not get the logic behind these formulas.
> Intuitively I would say that at least Xr and Yr should be
> switched in the Ygeo formula, but don't waste time on explaining if
> I am wrong, this is pure speculation.

Marian,

I did screw this up.  It should be:

Xgeo = W[4] + W[0] * Xr + W[2] * Yr
Ygeo = W[5] + W[1] * Xr + W[3] * Yr

> The point is that I need to understand the real significance af these
> parameters, as I will have to compute them for my maps.
> What I actually need is to be able to define a rotation around the
> Z axis, that is to specify that my new Oy axis makes "alfa" degrees with
> the North direction.

Right.  Given a pixel width of PSx and a pixel height of PSy and an
origin of (Ox,Oy) you would compute the coefficients something like:

W[0] = cos(alfa) * PSx
W[2] = sin(alfa) * PSy
W[1] = -sin(alfa) * PSx
W[3] = cos(alfa) * PSy

However, I often get the signs wrong for the W[2] and W[1] values
so fool around a bit till it works.

> You posted once the info in a GeoTIFF, containing a 4x4 matrix:
> W(0)    W(1)    0    W(4)
> W(2)    W(3)    0    W(5)
> 0            0        0        0
> 0            0        0        1
> which leads me to the idea that you multiply something like:
> [Xgeo Ygeo Zgeo ?]' = (4x4) * [Xr Yr Zr ?]'
> where [A]' is the transpose of A.
> Is this correct?
> 
> I also found a post suggesting to use Proj
> (http://mapserver.gis.umn.edu/data2/wilma/mapserver-users/0201/msg00146.html
> ). Is this the way to do it?
> If yes, is LCC the only projection that can be used?

I never tried this method.  It shouldn't really be necessary unless you want
to produce rotated output maps.  I assumed you are trying to utilize rotated
input raster data.

>>Note that MapServer does not support producing rotated map results.  They
>>are always north up.
> 
> Does this mean that if I am able to define a deviation from North,
> the map will come out rotated? ("always North up")
> 
> Sorry if some questions are trivial, but I do not have a background in
> geographical coordinate systems. If you know some documents that might
> explain these rotation coefficients, please give me a link. Thanks.

The questions aren't trivial, and I have a hassle to work out the proper
deriviation of the rotational coefficients every time I need to do so.

If you have further questions you might want to email me directly so we don't
contribute too much to the mapserver-users traffic.  Perhaps you could
summarize to the list once you have gotten everything working.

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent





More information about the mapserver-users mailing list