colorworld is a basic python library and command line utility for producing colored world maps from lists of data for countries of the world.

It produces svg images like those below, which can be rendered to other image formats using a program like inkscape.

Sample colored world map

These images will have a consistent appearance to many similar maps on Wikipedia. So this program may be useful for standardizing the production of such maps on Wikipedia from data files. If data sources are linked to from these images in Wikipedia this would allow these maps to be easily modified.

Installing

Using as a library

Sample Usage
from colorworld import make_map

# from dictionary
prop_french_speakers = {'fr': 0.99', 
    'gb': 0.05,
    'ca': 0.5,
    'es': 0.2}
make_map(prop_french_speakers, 'output1.svg')

# from stream
make_map(file('data.csv'), 'output2.svg')

# from file
make_map('data.csv', 'output3.svg')
Documentation
Make a colored world map for some data.

    target should be the path to an output file.

    stream_file_or_dict must be one of
     * The path to a csv of two-letter-country-codes and numeric values
     * A stream containing such values
     * A dictionary mapping two-letter-country-codes to numerical values

    These two letter country codes are those specified by ISO 3166.

    The keyword args which can be given are:
     * hue: specify the hue for the color-scheme (between 0 and 360)
         (default 120)
     * output: output map to FILE. (default is an svg-file
         corresponding to the input file or output.svg) (default '')
     * divisions: Number of shades to use when color-coding (default
         5)
     * unit: Symbol which should be used for units (default 'kg')

     * multiplier: Scale values down by a power of ten (default 0)

     * long_names: data uses long (english) country names instead of
         ISO codes. Try to interpret these. (default None)

Command line utility

Sample usage
Documentation
Usage: color-world.py [options] [CSVFILE]

Produce an svg world-map showing numerical data for countries by
shading each according to its numerical value. The input file
must be a CSV file consisting of ISO 2 letter country codes and
their values. If no input file is given standard in is used.
This list does not need to be complete.

Options:
  -h, --help            show this help message and exit
  -H HUE, --hue=HUE     specify the hue for the color-scheme (between 0 and
                        360)
  -o FILE, --output=FILE
                        output map to FILE. (default is an svg-file
                        corresponding to the input file or output.svg)
  -d DIVISIONS, --divisions=DIVISIONS
                        Number of shades to use when color-coding
  -u UNIT, --unit=UNIT  Symbol which should be used for units
  -m EXPONENT, --multiplier=EXPONENT
                        Scale values down by a power of ten
  -l, --long-names      data uses long (english) country names instead of ISO
                        codes. Try to interpret these.