JavaScript and Maps (in that order)

Map Projections are Fundamentally Broken

I have previously made my dislike of projections clear my work on proj4js has led me to has caused me to decide that it is not map projections that are necessarily wrong, it’s that the way they are implemented is fundamentally broken. 

Reason For Being

Projections are the mathematical formulae for putting location data, fundamentally spherical in nature, onto a planar surface (one with euclidean geometry vs spherical geometry). The difficulty faced in projections is that it is impossible to make a perfect one, all projections will fail to accurately preserve angles, areas, directions, shapes or other factors across the globe.  Any will preserve some of them at the expense of others (this is where all the Mercator hating comes from, Mercator preserves shape and angle at the expense of size).  

When most people think of projections they think of a globe and the whole world, but most maps are made on a local scale, where these trade offs are less relevant.  When I’m making a map of Massachusetts I don’t care what Asia looks like so I can use a projections that preserves area, angle, shape, etc inside Massachusetts while making Asia and South America unrecognizable.  This principle is what’s behind the American state plane system which divides the US into 126 different zones and comes up with a projection for each of them. 

These days it’s relatively easy to convert between a lat long coordinate to a projected x y coordinate.  But this is a relatively recent thing, it is not easy to do it with pencil and paper, there are a lot of trig operations involved. So it makes sense to minimize conversions between to and from lat long coordinates. Thus you’d store your data in projected x,y coordinates, it doesn’t really matter that you are using a different system than someone in another state, it matters whether your using the same system as the surveyor out in the field. 

Fast Forward to Today

Most of the reasons for keeping raw data projected are gone, but since almost all GIS houses are lumbering legacy behemoths they still do. But oh hey the internet is here and suddenly people are aggregating data from lots of different places and finding that stuff from different agencies are all in different formats. 

Now if there were only a few types this wouldn’t be that big of a problem, but remember that 126 number I mentioned earlier? there isn’t just one projection for each zone, for the mainland of Massachusetts EPSG has 5 and ESRI has 4 plus some custom ones people uploaded which we will ignore. so 126 x 9 = 1134 just for America. actually lists 4362 in the EPSG scheme and 447 in the ESRI scheme plus 2380 IAU2000 scheme. 

This wouldn’t be a problem either except the way many programs refer to projections is just by number. Which is fine for a desktop program but unacceptable for a web program, EPSG + ESRI is a megabyte. You can’t build that into a web library. 

For a web library it’s pretty much a given that you’re going to have to force your users to describe the projection to you if they are doing stuff with data that is not in a lat long format. 

Good thing there is a great format for expressing that kind of data.

Just Kidding There Are Like 10 And They Are All Terrible

Seriously there are 16 listed on a page through there are only 3 people actually use. they are

  • proj4, a series of key=value statements separated by a space and each one preceded by a plus sign.  
  • WKT, a format that makes a person yearn for a format as human friendly as XML and seems to be an attempt to create something like lisp but less intuitive and user friendly.
  • ESRI WKT, exactly the same as WKT except ESRI is like fuck you guys we’re going to name all the parameters something else. 

Again let me point out that all of these are essentially key value stores but NONE of them are in any sort of real format meaning just to get the parameters out you have to use a custom parser that is just for projections. 

So for the moment, if your going to release data do us all a favor and release it as lat long data in WGS 84, and not the custom projection that only your half of the office uses. 

  1. cwmma posted this