How to create tiff world file - tfw

Aaron Racicot aaronr at ECOTRUST.ORG
Fri May 27 15:45:39 EDT 2005


Dave,

Well there are several issues that you point out.  I will try to address
what I can and leave it to the rest of the list group to chime in if you
still have questions:

1) This map you refer to comes with its own tfw file, so you can not
just change that file with out changing the tif file as well... they
must correspond.

2) The x/y pixel sizes are calculated by taking the extent and dividing
by the number of pixels in a given direction.  In the case of your map
you sent me was 1984, 1593 pixels.  You also told me the corners of the
map:

TL 35 00.0000 079 00.0000
BL 33 00.0000 079 00.0000

TR 35 00.0000 076 00.0000
BR 33 00.0000 076 00.0000

So, the x extent = 79-76 = 3 degrees.  Divide by 1984 pixels and you get
the 0.00151209677419.  Do the same for y, remembering that it is
negative (world file is upper left corner referenced).

3) As you can see, the world file is directly related to the extent of
the image you are using, so you can not just "shift" or modify the world
file.  What you can do is keep the world file the same, but define the
projection of the layer to be correct so it lines up.  You will need to
do something like (I have not tried this definition, it is just a guess)
this for your layer:
    PROJECTION
      #Mercator Projection
      "proj=merc"
      "ellps=wgs84"
      "lon_0=0"
      "lat_ts=34.1666666666667"
      "x_0=0"
      "y_0=0"
      "units=feet"
    END

4) One last point on the tfw, the last 2 numbers are the upper left
corner, but the center of the pixel, so you will have to add
.5*pixel_width to the actual corner coordinate.  Let me know if this
does not make sense.

5) Oh, one more... the 2nd and 3rd numbers deal with rotation of the
image and I have not dealt with images that have non-zero values here...
you need to be careful with these and make sure not to get rid of them.

Finally, I would suggest you read up on GDAL and specifically the
utilities like gdalinfo which can go along way toward telling you about
an image.  It is a great way to check if your world file is interpreted
correctly.  Here is some sample output from the Bathy image you sent me:

[aaronr at pearl nc_fish]$ gdalinfo Bathymap.tif
Driver: GTiff/GeoTIFF
Size is 1984, 1593
Coordinate System is `'
Origin = (-79.000000,35.000000)
Pixel Size = (0.00151210,-0.00125549)
Metadata:
  TIFFTAG_XRESOLUTION=150
  TIFFTAG_YRESOLUTION=150
Corner Coordinates:
Upper Left  ( -79.0000000,  35.0000000)
Lower Left  ( -79.0000000,  33.0000000)
Upper Right ( -76.0000000,  35.0000000)
Lower Right ( -76.0000000,  33.0000000)
Center      ( -77.5000000,  34.0000000)
Band 1 Block=1984x1 Type=Byte, ColorInterp=Red
Band 2 Block=1984x1 Type=Byte, ColorInterp=Green
Band 3 Block=1984x1 Type=Byte, ColorInterp=Blue
Band 4 Block=1984x1 Type=Byte, ColorInterp=Undefined
[aaronr at pearl nc_fish]$

Hope this helps....

And BTW, try to direct general questions like this to both me and the
list as there are many people out there with more knowledge in this area
and the messages get in the archives to help others in the future.

Good luck!

Aaron

-----Original Message-----
From: Dave [mailto:wildrov at bellsouth.net] 
Sent: Friday, May 27, 2005 12:06 PM
To: Aaron Racicot
Subject: Re: [UMN_MAPSERVER-USERS] Easy $100.00 for the working example

Greetings Aaron,
I was messing with some other maps today and I have a questions about
how 
you did the tfw file for the bathy map.

I have an off the shelf Coastal Map in tif format.  It comes with a tfw 
file.

8.0002234142550677
-0.000187013052522995370
-0.0000663554134505283410
-7.9996543918969518
-7200069.4222917529
3389600.3512264267

Name:    NEW RIVER INLET TO CAPE FEAR NORTH CAROLINA
Units:    Feet
Scale:    80000
Date:    07/14/01
Projection:   Mercator
Spheriod:   WGS84
Central Meridian:  0.00
Latitude of True Scale:  34.1666666666667
False Easting:   0.00
False Northing:   0.00
Produced By:   Annemieke Smith
    NOAA/OCS/CSDL/CGTP

My guess is it is in a different datam.  When I load it on the map
server it 
winds up off in the ocean some where.  SOooo....I have the tif and was
just 
going to make my own.

My question is how did you make the file for the Bathy map?  Is there a 
program that you use for this?


The first coefficient is the X pixel size and The fourth is the Y pixel
size 
and I guess this is where my question is.....


I know where the last two numbers come from...lat and long from the 
corners....but how did you get the first and forth?

from the Bathy map....
0.00151209677419
0
0
-0.00125549278092
-78.9992439516
34.9993722536

How do you figure out the x and y pixel size?


Dave



More information about the mapserver-users mailing list