Maidenhead grid -- longitude / latitude calculator not limited to 6 characters

Maidenhead is a grid system used by amateur radio operators. I crudely implemented a Maidenhead grid to longitude/latitude calculator, not limited to the 6 characters as often seen with other programs. Written in newbie python here on debian GNU/Linux. Download: lonlat2maiden, maiden2lonlat. See my notes, and Rene Kanters' 2004 augmentations.

First, in case you use DMS notation, convert it into decimal degrees,

$ set 120d51\'57.74\"E 24d10\'54.14\"N
$ echo $1 $2
120d51'57.74"E 24d10'54.14"N
$ set $(echo $1 $2|cs2cs +proj=latlong -f %.8f)
$ echo $1 $2
120.86603889 24.18170556

Now we are ready to go,

$ echo $1 $2|lonlat2maiden
PL04KE
$ echo $1 $2|lonlat2maiden 22 #arbitrarily picking 22
PL04KE33WO16WF07TP38UR
$ echo $1 $2|lonlat2maiden 22|maiden2lonlat
120.86603889 24.18170556
$ echo $1 $2|lonlat2maiden 22|maiden2lonlat|cs2cs +proj=latlong
120d51'57.74"E  24d10'54.14"N 0.000

By the way, as to just how many digits one needs for what granularity, we examine what the smallest length one can distinguish with the latitude parameter as we increase string length:

Len      meters example
 2 1111200.0000 PL
 4  111120.0000 PL04
 6    4630.0000 PL04KE
 8     463.0000 PL04KE33
10      19.2917 PL04KE33WO
12       1.9292 PL04KE33WO16
14       0.0804 PL04KE33WO16WE
16       0.0080 PL04KE33WO16WE57
18       0.0003 PL04KE33WO16WE57NA

So, to dazzle your friends with millimeter precision, one need not make one's vanity Maidenhead locator too long after all. (Code used to make above output)

Hmmm, the Maidenhead system is sort of like Taiwan Power Company grids.


Dan Jacobson

Last modified: 2007-09-14 01:10:18 +0800