Mapping Hacks

by Schuyler Erle, Rich Gibson and Jo Walsh

« Douglas-Peucker Line Simplification in Python Gigapans and Quadtrees »

Geohash implemented in Python

May 29th, 2008 by Rich

Schuyler wrote a python module to support the Geohash latitude/longitude encoding system created by Gustavo Niemeyer. (wikipedia link).

Schuyler’s python implementation of geohashing code is here.

Geohashing is not to be confused with the more amusing but arguably less useful xkcd geohashing, an implementation of that code lives here .

There is of course also an implementation on the CPAN.

I’ve been doing a lot of thinking about geoprivacy, and during Where 2.0, between taking Gigapans, I wrote up some code to show geohash bounding boxes at different levels of precision in KML.

This example shows the center points for each geohash center point as I drop the number of digits in the geohash.

geohash bounding boxes

9qbbbujv5n center (38.123451769352, -122.654322981834) bbox diagonal distance= 1.96944 feet
9qbbbujv5 center (38.1234383583069, -122.65430688858) bbox diagonal distance= 15.650976 feet
9qbbbujv center (38.1235027313232, -122.654285430908) bbox diagonal distance= 62.612352 feet
9qbbbuj center (38.1232452392578, -122.654800415039) bbox diagonal distance= 500.898288 feet
9qbbbu center (38.1253051757812, -122.656860351562) bbox diagonal distance= 2003.59368 feet
9qbbb center (38.12255859375, -122.67333984375) bbox diagonal distance= 3.0357480 miles
9qbb center (38.056640625, -122.51953125) bbox diagonal distance= 12.1429919 miles
9qb center (38.671875, -123.046875) bbox diagonal distance= 97.1439353 miles
9q center (36.5625, -118.125) bbox diagonal distance= 388.5757413 miles
9 center (22.5, -112.5) bbox diagonal distance= 3108.6059307 miles
Some of the jumps work visually better than others. I suspect that is perceptual - we have non linear perceptual response curves :-/
A sample of the kml output is here and this is the perl to generate that kml.

Posted in Uncategorized |

You can follow any responses to this entry through the RSS 2.0 feed. Trackback from your own site.


Leave a Reply

You must be logged in to post a comment.


Entries (RSS) and Comments (RSS).