Friday, February 5, 2021

Albers Projection for Maps

 I wrote this Python code a couple months ago when I needed a simple stand-alone way to plot cities on an SVG representation of a map.  There were no good, standalone Python references I could find.  Even when I found something in other languages, the readability of it was somewhat lacking.  

It seems the more math you know, the fewer characters you put in your variable names. Sigh.  Are they using meters or miles? Are they using radians or degrees? You have no idea from looking at the code, so you *have* to understand the math to be able to decipher it.

Developing this code required some investment of time in not just the math, but the geographic uses of the Albers projection. I figured it might be generally useful, so have made the code available in GitHub here:

https://github.com/cassandra/geo_maps

It includes an example that deals with some tricky issues that can come up if you want to plot points against a map of the U.S.  

When you see those U.S. maps where they have relocated Alaska and Hawaii to be in the lower left of the map, it is obvious they are not in the right location and are of different scale than the contiguous 48 states. However, did you know that they are using completely different projection parameters *and* have rotated them?  I learned this the hard way.


No comments: