Your search returned no results

Try another search term or view Stack Exchange, where we have active conversations with Developers about GIS.
    Support channel in Stack Exchange

    Thousands of developers around the world have helped make CartoDB a success, and we have active conversations with them about GIS in Stack Exchange.

    Go to Stack Exchange

    Map Election Results


    This tutorial describes the basic functionality for connecting to a dataset and building a thematic map of electoral data, using the following workflow:

    Locating Electoral Data

    For this tutorial, we are going to build a map with data from the the Harvard Election Data Archive website, which contains data from United States elections. In particular:

    To understand the data, it is often helpful to view its metadata. In this case, go back to the Harvard Election Data Archive, search for and download the NH-Notes.rtf file, and open the metadata with a text-editor. The metadata describes all the columns and information contained in the downloaded file. For example, the column p_08 is the Democratic vote share for the presidential race in 2008. This is what we will use to create an interesting map.

    Map the Average Democrat Share

    After file is downloaded, connect the dataset to CARTO. When the dataset is successfully imported, it displays in the DATA VIEW. Scroll across the Data View and note the column p_08, that we identified as the column that contains the Democratic vote share.

    Table view

    Click on MAP VIEW to visualize the data. You will see basic outlines of the New Hampshire counties. Change the Basemap.

    Map view

    Thematic Map of Results

    Create a choropleth map of this data.

    • Click the wizards option from the CARTO sidebar
    • Select CHOROPLETH as the thematic map type
    • Change the visualized Column data to display p_08
    • Display 5 Buckets for the Buckets option
    • Optionally, change the color ramp. Note how your may styling is changing appearancef

    Cloropeth view

    Customizing Thematic Maps

    Although CARTO makes it simple to create thematic maps, we also give you the flexibility to customize styles for select data. The map we have created looks okay, but a linear color ramp is not normal for this type of data. The electoral data is showing results greater than 0.5 (from the p_08 column) as primarily Democrat votes. Data containing less than 0.5, indicates mostly Republican votes. You can apply a diverging scale (using Red/Blue) to represent the more familiar U.S. electoral party colors.

    Tip: A recommended source for basic color scales, and good mapping colors, is Color Brewer 2. For example, select a diverging ramp of 5 colors from red to blue, #0571B0, #92C5DE, #F7F7F7, #F4A582 and #CA0020.

    Manually Editing CartoCSS

    You can apply advanced CartoCSS styling with the CartoCSS Editor. CartoCSS colors are coded in hexidecimal, so #FFFFFF is white, #000000 is black, and so on. For the purposes of this tutorial, we will apply the five new colors we identified from ColorBrewer (in the previous section). You can copy and paste hexidecimal colors into the CartoCSS Editor. Click Apply Style to view the results.

    Customized colors

    Note: We have incorrect bins. Notice that our colors do not include the far ends of the spectrum, near 1. Edit the bins to be <=1, <=0.6, <=0.52, <=0.48 and <=0.4 (most red), and click Apply Style.

    Fixed buckets

    The data is not perfect yet. Note that the white, in the areas that are split, is too bright compared to the rest. Change the color after <=0.52 to #EEEEEE.

    Fixed middle bucket

    Great, now you have a nice looking election map!