Raster layer - Howto?
Brent Fraser
bfraser at GEOANALYTIC.COM
Thu Nov 1 07:23:54 PDT 2007
Pascal,
I would guess the data is in a geographic coordinate
system. This means the units of coordinates and pixel sizes
for the image would be degrees not meters. I would also
assume that the image covers the entire Earth, not just a
part of it, so:
Calculating the X (longitude) pixel size, 360 degrees covers
the Earth all the way around:
360 degrees / 8192 pixels = 0.0439453125 degrees per pixel
in X
Calculating the Y (latitude) pixel size, 180 degrees covers
the Earth pole to pole:
180 degrees / 4096 pixels = 0.0439453125 degrees per pixel
in Y
Notice the pixel size in X is the same as Y. This is
typical for a raster map (but not a hard rule).
---------------
And now for a reality check. Approximately how many
meters-on-the-ground is each pixel?
0.0439453125 degrees/pixel * 60 minutes/degree * 60
seconds/minute * 30 meters/second (approx) = 4700
meters/pixel
Interesting information, but not needed for the tfw file.
---------------
So back to the calculations for the tfw file:
The coordinates of the upper-left corner of the upper left
pixel would be
X = -180 degrees
Y = 90 degrees
But the tfw file specifies the MIDDLE of the upper left
pixel (so we need to subtract half a pixel width from each
coordinate):
X = -180 + 0.0439453125/2 = -179.97802734375
Y = 90 - 0.0439453125/2 = 89.97802734375
So the tfw file would be:
0.0439453125
0
0
-0.0439453125
-179.97802734375
89.97802734375
One more step for Mapserver:
Since the tiff file is not a geotiff, you need to tell
mapserver the coordinate system of the raster file. So your
layer definition in the the map file would be (note the
PROJECTION object):
########## NASA BLUE MARBLE ###########
LAYER
NAME "satellite"
DATA "/var/www/odamap/blue_marble.tif"
TYPE RASTER
PROJECTION
"geographic"
END
METADATA
"wms_title" "ODAdata WMS Server SATELLITE"
END
END
#######################################
Brent Fraser
GeoAnalytic Inc.
Calgary, Alberta
----- Original Message -----
From: "Pascal Ehlert" <dadark at DADARK.DE>
To: <MAPSERVER-USERS at LISTS.UMN.EDU>
Sent: Thursday, November 01, 2007 5:15 AM
Subject: Re: [UMN_MAPSERVER-USERS] Raster layer - Howto?
> Siki Zoltan wrote:
>
> > 0.15 (A) pixel size in nature in x direction (e.g. 15
cm resolution)
> > 0.0 (D) depends on rotational angle, afaik it must be
zero for
> > mapserver
> > 0.0 (B) same as above
> > -0.15 (E) negative pixel size in nature in y direction
> > 1234.56 (C) x position of the center of the pixel at
upper-left corner
> > 4567.89 (F) y position of the center of the pixel at
upper-left corner
>
> Okay, I was able to figure out the first four values now!
> The data has a resolution of 1km/px so I want something
like
> 1000.00
> 0.00
> 0.00
> -1000.00
> there, is that correct?
>
> The only thing I'm unsure about are the last two values.
> It is an image of the whole world, so shouldn't that be
something
> like -180.00 for the first value and 90.00 for the last?
>
> When using these values gdalinfo gives me a strange output
for the
> offsets which can't be correct.
>
> Sorry to bother you again.
>
>
> Pascal
More information about the MapServer-users
mailing list