Archive for January, 2009


Miller Projection

January 23rd, 2009

I was talking to my colleague the other day about a problem he was having with a new Location Editor that he was making for the university. The goal of the program was to take Latitude/Longitude coordinates and transpose them to (x,y) coordinates on a image of a map. I do want to put a disclaimer that my colleague basically did all the work to solve this problem. I am merely describing the math of his solution.

In stating the obvious, the planet we live on is basically a sphere. However, because we only live on the surface, we still only have two dimensions to map. However, in order to represent the surface of the earth, we will need some kind of projection which will change (Latitude,Longitude) coordinates to (x,y) coordinates. I am going to be using a World Map which uses a Miller Projection. However, you can easily use a different projection like a Mercator projection or a Gall-Peters projection.

A Miller projection is obtained by projecting all points on the surface of the earth onto a cylinder.

Once you projected the earth onto a cylinder, you can then unroll the cylinder surface onto a plane. If you do this, you will get the following world map.

It can be shown that the x,y coordinates can be obtained by the following relationship. Please note that the longitude and latitude are in radians not degrees.

 x = longitude
 y = 1.25 \cdot ln(tan(\pi / 4 + .4 \cdot latitude))

However, in order to project these x,y coordinates onto an image, we are going to need to change these formulas a bit. First off, the miller coordinates (which I will represent as x’,y’ from now on), assumes the following coordinate system.

The big things to note about the coordinate system is that
1) y=0 runs across the equator.
2) x=0 runs across the prime meridian.
3) The range of possible values are roughly x = 0 .. 6.28 and y =-2.30 .. 2.30.

However, we don’t care about the Miller Coordinate system. We want to use the coordinate system of the image. First off, the image coordinate system uses pixels as a unit length instead of a miller unit. Secondly, the y axis in the image coordinate system is in the opposite direction as the miller y’ axis. This is because (x,y)=(0px,0px) should be the top-left corner of the image which is the standard coordinate system that computers use for images. And lastly, the image doesn’t have to be the entire world map. The image could be an image of North America instead of the World.

This means we will have to apply the following projections (Long, Lat) \rightarrow (x^\prime,y^\prime) \rightarrow (x,y).

First, before I describe the transformation, I want to define the following constants:
 LeftLong = Longitude ~ of ~ Left ~ Side ~ of ~ the ~ Image
 RightLong = Longitude ~ of ~ Right ~ Side ~ of ~ the ~ Image
 TopLat= Latitude ~ of ~ Top ~ of ~ the ~ Image
 BottomLat= Latitude ~ of ~ Bottom ~ of ~ the ~ Image
 ImageWidth = Width ~ of ~ Image ~ in ~ Pixels.
 ImageHeight = Height ~ of ~ Image ~ in ~ Pixels.

As I mentioned above, the Miller projections are defined as:
 x^\prime = M_x(long) = long
 y^\prime = M_y(lat) = 1.25 \cdot ln(tan(\pi / 4 + .4 \cdot lat))

All we need to do is to apply the following transformation to get from (long, lat) to (x, y).

 x = (M_x(long)- M_x(LeftLong)) \cdot (\frac{ImageWidth}{M_x(RightLong)- M_x(LeftLong)})
 y = (M_y(TopLat)- M_y(lat)) \cdot (\frac{ImageHeight}{M_y(TopLat)- M_y(BottomLat)})

The nice thing about this formula is that it is really easy to move to a map with a different projection. All you need to do is to apply a different projection function for M_x(long) and M_y(lat). For example, the Mercator projection would have the functions:

 x^\prime = G_x(long) = long
 y^\prime = G_y(lat) = ln( tan(lat) + sec(lat))

Another Karl Popper Quote

January 19th, 2009

The empirical basis of objective science has thus nothing ‘absolute’ about it. Science does not rest upon rock-bottom. The bold structure of its theories rises, as it were, above a swamp. It is like a building erected on piles. The piles are driven down from above into the swamp, but not down to any natural or ‘given’ base; and when we cease our attempts to drive our piles into a deeper layer, it is not because we have reached firm ground. We simply stop when we are satisfied that they are firm enough to carry the structure, at least for the time being.

Karl Popper in
The Logic of Scientific Discovery

Hot, Flat and Crowded

January 13th, 2009

I found a great public lecture at the London School of Economics and Political Science on global warming. The lecture is called Hot, Flat and Crowded by Thomas L Friedman. You can listen to the mp3 or buy the book (which I have never read). The author is definitely American, but it does show a lot of the problems that need to be addressed in the next century.

Karl Popper Quote

January 11th, 2009

There can be no human society without conflict: such a society would be not a society of friends but of ants.
- Karl Popper

2009 Reading List

January 11th, 2009

It is around this time when everyone starts making new years resolution. One of the things I wanted to do this year was to keep track of all the books that I have read. I am very interested in how many books that I actually read in a year.

Anyways, I started a list that you can find here. If anyone wants to make similar reading lists, please leave a comment. I would be interested in seeing what everyone else is reading.