Tools for generating choropleth maps
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Perl Choropleth

Choropleth maps are those geographical maps where different regions/counties are colored differently, like election results, etc.

The super easy way to generate them is to take SVG and transform it. This little script does exactly that, in perl.

It requires XML::Parser, which you might be able to install by doing yum install perl-XML-Parser. If that works, you win.

The script parses an SVG source file and modifies colors. It's currently set up to use this awesome public domain map of the USA. I made a few modifications to the source map to fix some bugs:

  • Worth, NO -> Worth, MO
  • Polk, WIO -> Polk, WI
  • Yukon-Koyukuk, AL -> Yukon-Koyukuk, AK

There are some example outputs along with the code to generate them.

Colors come from ColorBrewer, which you should use too.