ChoroMap is a simple ruby script (and some blank maps from wikimedia) to make a colorized map of the USA based on count data. That is, given a data file with an identifier (ie. a FIPS code or state abbreviation) and an associated count (ie. number of bars, number of sex offenders, unemployment, etc ) you can quickly and easily generate a map like the one shown here:
Which, incidentally, is what inspired this script in the first place.
./choro_map.rb <datafile> <map_type> > <output.svg>
Where it is assumed your “datafile” has rows that look like:
“identifier” “\t” “count”
and identifier is a county code or state abbreviation depending on whether “map” is
“usa” or “counties”. See sample data.
Using the Geo to FIPS utility
Wait! But my data doesn’t have fips codes in it! All I’ve got are these stupid (lat,lon,count) tuples!
If, instead of “fips” “\t” “count”, you have “lat” “\t” “lon” “\t” “count” don’t get frustrated just yet. There’s a script for that.
From the command line:
cat /your/data/file | bin/geo_to_county_streamer.rb --map | sort | bin/geo_to_county_streamer.rb --reduce > happy_datafile.tsv
OR if you have a HUGE datafile you can run it in Hadoop mode. Of course, this is assuming you’ve got a Hadoop cluster lying around,
which, frankly, you should if you have HUGE data.
bin/geo_to_county_streamer.rb --rm --run /input/data/file /output/datafile
The output is then ready to use with ChoroMap.