How to Create a Counties Visited Map with a Perl Script

While there are online tools allowing people to track their travels, it's nice to be in full control of your travel data. If a site containing your travels were to go away, could you recover?

This Perl script generates an SVG file. Did you realize SVG files are simply text files? They can be viewed as an image or converted into a more traditional image format such as jpg.

The script defines a rather lengthy header and footer, which it prints with a small section in between.

foreach(<DATA>) {
    chomp;
    next if (/^#/);
    ($state,$fips1,$fips2,$county,$class,$color) = split /,/;

    if ($color ne "") {
        print "  #c${fips1}${fips2} {fill:${color}}\n";
    }
}

Perl allows embedding data in the script itself, which I have done. I parse that data section, extract the FIPS code, and assign a color. I use blue for counties visited and red for counties where I've lived. You have total freedom to do what you want.

Below is a snippet of the data.

__DATA__
AL,01,001,Autauga County,H1,
AL,01,003,Baldwin County,H1,
AL,01,005,Barbour County,H1,
AL,01,007,Bibb County,H1,
AL,01,009,Blount County,H1,
AL,01,011,Bullock County,H1,
AL,01,013,Butler County,H1,
AL,01,015,Calhoun County,H1,

Suppose I lived in Autauga and visited Baldwin. I would add the appropriate colors.

__DATA__
AL,01,001,Autauga County,H1,red
AL,01,003,Baldwin County,H1,blue
AL,01,005,Barbour County,H1,
AL,01,007,Bibb County,H1,
AL,01,009,Blount County,H1,
AL,01,011,Bullock County,H1,
AL,01,013,Butler County,H1,
AL,01,015,Calhoun County,H1,

You can use the entire RGB palette of colors to mean anything you want.

Download script

counties.pl