Difference between revisions of "User:Wenslayer/KMLGenerator"

From Geohashing
imported>Wenslayer
(New page: I've created a script that can take the data from [http://www.amipsychic.net/geohashing.html here] and with a few inputs, generate a .kml file to read into Google Earth so you can see all ...)
 
imported>Wenslayer
(Tidied up page)
Line 1: Line 1:
I've created a script that can take the data from [http://www.amipsychic.net/geohashing.html here] and with a few inputs, generate a .kml file to read into Google Earth so you can see all the Geohash points of the dates selected.
+
== Problem ==
  
Screen shot:
+
Have you wondered what historical Geohashes have occurred in your graticule?  Have you wanted to see them all at once, instead of typing each date in via peeron?  Well this script might help you out here.
  
[[Image:KML Generator - Google Earth screen shot 1.jpg]]
+
== Solution ==
 +
I've submitted a script to the [http://public.perforce.com:8080 Perforce Public Depot]; the script can be downloaded here:
 +
* [http://public.perforce.com:8080/@rev1=head@//guest/marc_wensauer/geohash/gen_geohash_kml.sh gen_geohash_kml.sh]
  
Note how few Geohash coordinates actually fall in Victoria and the Saanich Peninsula?  Should make it easy to sweep up those retro Geohashes.
+
== Usage ==
 +
<pre>
 +
Usage: gen_geohash_kml.sh -g <graticule> [-s <source file>]
 +
        -g: specify the graticule of interest (form: <latitude,longitude>)
 +
        -s: source file to use (file format: YYYY-MM-DD,<DOW>,<LAT>,<LON>)
 +
                default: '-' for standard input
 +
 
 +
Notes:
 +
* You can get *all* retro Geohash data from:
 +
  http://www.amipsychic.net/geohashing.html
 +
* Resulting KML file is displayed to standard out.
 +
* You may wish to pre-process the source file to only show dates of interest.
 +
  E.g.: grep "^2009" allcoords.csv | gen_geohash_kml.sh -g 49,-123 > 2009.kml
 +
 
 +
Reference:
 +
* http://wiki.xkcd.com/geohashing/
 +
</pre>
 +
 
 +
== Examples ==
 +
 
 +
Using the source data, Geohash coordinates can be generated for every day since October 1st, 1928 (over 80 years worth), so with a little filtering, you should be able to generate a KML file for whatever date range and graticule you'd like.
 +
 
 +
Examples:
 +
* Generate a KML for the [[Surrey, British Columbia|Surrey]] graticule of all possible Geohash coordinates since October 1st, 1928 (over 29,000 points!):
 +
<pre>
 +
$ wget -qO http://www.amipsychic.net/coords/allcoords.csv.bz2 |
 +
      bzip2 -d | gen_geohash_kml.sh -g 49,-122 > 49,-122_all.kml
 +
</pre>
 +
 
 +
* Generate a KML for the [[Vancouver, British Columbia|Vancouver]] graticule of all Canada Day and Christmas Day dates:
 +
<pre>
 +
$ wget -qO http://www.amipsychic.net/coords/allcoords.csv.bz2 |
 +
      bzip2 -d | sed -nre '/-(07-01|12-25)/p' |
 +
      gen_geohash_kml.sh -g 48,-123 > 48,-123_7.1_12.25.kml
 +
</pre>
 +
 
 +
* Generate a KML for the [[Victoria, British Columbia|Victoria]] graticule of all dates since the original Geohash webcomic (May 21st, 2008):
 +
<pre>
 +
$ wget -qO http://www.amipsychic.net/coords/allcoords.csv.bz2 |
 +
      bzip2 -d | sed -ne '/^2008-05-21/,$p' |
 +
      gen_geohash_kml.sh -g 49,-123 > 49,-123_since_2009-05-21.kml
 +
</pre>
 +
 
 +
:Screen shot:
 +
:[[Image:KML Generator - Google Earth screen shot 1.jpg]]
 +
 
 +
Note how few Geohash coordinates actually fall in Victoria and the Saanich Peninsula?   
 +
 
 +
== To Do ==
  
To do:
 
 
* Convert script from Bash to Perl to run faster.
 
* Convert script from Bash to Perl to run faster.
* Allow sourcing data from a file or URL
+
* Automate retrieval and decompression of source data.
* Pretty-up each placemark's description to include hyperlinks to this Wiki and peeron map.
+
* <s>Pretty-up each placemark's description to include hyperlinks to this Wiki and peeron map.</s> Done; don't need link to peeron map (you're in a mapping application already!)
* Add format checking of source data
+
* Add format checking of source data.
 
* Properly account for W30 graticules.
 
* Properly account for W30 graticules.

Revision as of 04:52, 16 June 2009

Problem

Have you wondered what historical Geohashes have occurred in your graticule? Have you wanted to see them all at once, instead of typing each date in via peeron? Well this script might help you out here.

Solution

I've submitted a script to the Perforce Public Depot; the script can be downloaded here:

Usage

Usage: gen_geohash_kml.sh -g <graticule> [-s <source file>]
        -g: specify the graticule of interest (form: <latitude,longitude>)
        -s: source file to use (file format: YYYY-MM-DD,<DOW>,<LAT>,<LON>)
                default: '-' for standard input

Notes:
* You can get *all* retro Geohash data from:
  http://www.amipsychic.net/geohashing.html
* Resulting KML file is displayed to standard out.
* You may wish to pre-process the source file to only show dates of interest.
  E.g.: grep "^2009" allcoords.csv | gen_geohash_kml.sh -g 49,-123 > 2009.kml

Reference:
* http://wiki.xkcd.com/geohashing/

Examples

Using the source data, Geohash coordinates can be generated for every day since October 1st, 1928 (over 80 years worth), so with a little filtering, you should be able to generate a KML file for whatever date range and graticule you'd like.

Examples:

  • Generate a KML for the Surrey graticule of all possible Geohash coordinates since October 1st, 1928 (over 29,000 points!):
$ wget -qO http://www.amipsychic.net/coords/allcoords.csv.bz2 |
      bzip2 -d | gen_geohash_kml.sh -g 49,-122 > 49,-122_all.kml
  • Generate a KML for the Vancouver graticule of all Canada Day and Christmas Day dates:
$ wget -qO http://www.amipsychic.net/coords/allcoords.csv.bz2 |
      bzip2 -d | sed -nre '/-(07-01|12-25)/p' |
      gen_geohash_kml.sh -g 48,-123 > 48,-123_7.1_12.25.kml
  • Generate a KML for the Victoria graticule of all dates since the original Geohash webcomic (May 21st, 2008):
$ wget -qO http://www.amipsychic.net/coords/allcoords.csv.bz2 |
      bzip2 -d | sed -ne '/^2008-05-21/,$p' |
      gen_geohash_kml.sh -g 49,-123 > 49,-123_since_2009-05-21.kml
Screen shot:
KML Generator - Google Earth screen shot 1.jpg

Note how few Geohash coordinates actually fall in Victoria and the Saanich Peninsula?

To Do

  • Convert script from Bash to Perl to run faster.
  • Automate retrieval and decompression of source data.
  • Pretty-up each placemark's description to include hyperlinks to this Wiki and peeron map. Done; don't need link to peeron map (you're in a mapping application already!)
  • Add format checking of source data.
  • Properly account for W30 graticules.