This post details how to calculate the latitude and longitude for the south east corner of a world file. This means you can calculate all you need to overlay a correctly scaled image in systems such as Google Earth.
A world file is a simple text file that accompanies a raster image enabling you to plot the image in it's correct geographic extent. It was introduced by GIS mammoth ESRI.
The snippet below represents the world file we will work on:
0.004437536880778 0.000000000000000 0.000000000000000 -0.004437792567264 -103.206013320465620 40.059054557563236
It is a bit incomprehensible at first, but if we add a bit of descriptive text to it for demonstration purposes, it becomes a little clearer:
0.004437536880778 <- Each X pixel represents this much longitude 0.000000000000000 0.000000000000000 -0.004437792567264 <- Each Y pixel represents this much latitude (negative) -103.206013320465620 <- Longitude of the upper left pixel (West point) 40.059054557563236 <- Latitude of the upper left pixel (North point)
The information here allows you to easily understand the geographic position of the image (i.e. that area of the Earth that it represents), but it does not contain sufficient information to accurately plot the image in Google Earth, for example.
A world file image
A world file is accompanied by an image file - be it a BMP, GIF, JPG, PNG, TIFF - it doesn't really matter to the world file. In order to calculate the east and south coordinates we need to know the width and height of the image in computer terms - how many pixels wide and high it is.
For this example we will use an image that is 6526 x 5208.
Calculating the eastern point
Running on the above example of plotting a world file and it's image in Google Earth, we need to calculate the most easterly and southerly points. Along with the image file itself, we have enough information to make this simple calculation:
east = west coordinate + (image width * line 1 of world file)
Remember that line 1 of the world file contains a number describing how much longitude 1 horizontal pixel of the image represents. So this would translate to:
east = -103.206013320465620 + (6526 * 0.004437536880778) east = -74.246647636508392
Calculating the southern point
Now all we need is the southerly point - as you might infer from the above point, it's pretty straightforward:
south = north coordinate + (image height * line 4 of world file)
Again, line 4 contains the amount of latitude each pixel in the image's height represents - the geographic distance.
south = 40.059054557563236 - 5280 * (-0.004437792567264) south = 16.947031
And now we have enough information to plot the world file and it's image onto Google Earth, or any mapping system of choice.
I'm sure there are countless tools that do this as part of GIS packages, but it is nice to know how to go about it step by step. If you're going to be working with mapping without using other packages, this is also an essential process if you wish to convert latitude and longitude coordinates to the screen, as it gives them a bounding box in which to scale themselves.
Feel free to post any comments or insights below, and any links to interesting GIS programming related posts or pages - a domain fairly new to me.