Here at Daily Kos Elections, community members have long used the free Dave's Redistricting App to demonstrate the possibilities for redistricting reform and the power of gerrymandering. However, a simple flat image can sometimes be hard to digest due to the variable size of districts, whereas an interactive, zoomable map is highly informative. Here I will show you how to turn your Dave's Redistricting Map into an interactive Google map like this one.
You can zoom in to see finer detail and clicking a district brings up stats like presidential electoral performance and demographics. Other advantages of making your maps interactive is that unlike DRA you won't need to make multiple images to show closeup zooms of urban areas and there are clearly defined borders between districts.
So how do you make a map like this? Head below the fold and I will walk you through it.
1. You will need a GIS, or Geographic Information System, program. I would recommend the free, open-source QGIS. Once you have QGIS installed, I would recommend going to Plugins>Manage and Install Plugins. Search for the plugins "Table Manager" and "OpenLayers Plugin," the latter of which is helpful if you want to use the Bing roads background that DRA uses, since you can set the shapefile layer style to be transparent in the Layer Properties.
2. With QGIS installed, you will need to have the shapefile for DRA's voting districts, which you can download here for nearly every state (except Kentucky, Montana, and Oregon). Shapefiles are a format for vizualizing geographic data and they contain at least four separate data files for one map, with the one you select to open ending in .shp. Open the state shapefile you want to work with in QGIS (note that to open a file rather than a project, it's ctrl+shift+V rather than ctrl+O).
3. When you've finished drawing the map in DRA that you want to make interactive, select the option to save the VTD info to an excel .csv. That file will have columns with the district number and a GeoID, which are the two that you need. Now open that .csv in QGIS.
4. With the shapefile and .csv both opened, double click on the name of the shapefile in the layers toolbox. When the layer properties window pops up, go to Joins and click the plus sign. That will ask you which other layer you wish to join to the map and which column to match between the two. Make sure to select the GeoID column and then click okay.
5. To confirm that the join worked properly, open the attribute table icon at the top toolbar, which looks like a spreadsheet. There shouldn't be any rows of null values in the GeoID or district columns. If this process worked properly, you need to right click on the map layer name and save it as a new ESRI shapefile so that the Join becomes permanent in the new file, otherwise when you remove one joined layer it detaches the data from the other one and doesn't save.
6. Once you have the new shapefile that has the district column added, you can delete all excess columns via the attribute table after you click the pencil to toggle on editing (click it again to toggle off and save/dismiss changes). To turn this shapefile from VTDs with district numbers into the district map itself, go to the menu option in the toolbar at the top and select: Vector>Geoprocessing Tools>Dissolve. Make sure that the input layer is the new shapefile and that the dissolve field is the district column. This will create a final new shapefile that should be the districts themselves.
7. Once you have created the district shapefile for your map, you will probably want to attach demographic or electoral data. To do this, simply make a new .csv of the desired data, make sure there's a district number column to match the shapefile's district numbers, and do another Join. If this data joined properly, then you're ready to save your map to a new shapefile one final time.
8. Instead of creating yet another new .shp shapefile, you can save the joined district map as a .kml file so that you will be able to to upload that format to Google Fusion Tables. You might also want to save this final join as a regular .shp shapefile as well though, in case you need to edit something later.
9. Input your file into Google and follow the steps to upload. It will create the interactive map file in your Google Drive account. Once it finishes uploading, you will be ready to format the map for presentation.
10. One annoying thing QGIS does is alter the column headers to add the table name, so once in Google you will likely need to edit the column titles and also get rid of the empty "Name" and "Descriptions" columns it adds by default. To change column names in QGIS you will need the Table Manager plugin, but note that the program limits title length, so it's probably better to just do this in Google. The way GIS programs works is by devising coordinates on the map itself, so you will have a geometry column with long strings of numbers that you very likely can just leave alone, but make sure not to delete it.
11. When you go to format the map itself, note that sometimes there is a bug where you need to refresh the page after the table is created (or delete the default "map of geometry" and add a new one), otherwise your changes won't stick. Aside from that small bug (Fusion Tables is still a work in progress), there are many different ways you can format your district map.
I like to set the borders to black and typically will set the district fill to color by a column instead of one color for all of them. To do that latter part, you will need a column where each district has a six character HTML color-code preceded by a #. So to get red you would set the row in the column to #ff0000. For more on how to find out the color codes for any particular RGB value, see here. For your convenience, here is a spreadsheet with the color codes for DRA's 55 default colors (which start repeating at 56).
You can also format by a gradient scheme or category buckets. For instance, one could map Obama's vote share by gradient, or divide it into categories with increments of five percent. When doing a gradient or bucket scheme, I typically like to turn the opacity up a little bit so that colors stand out more, but that's personal preference. You can also add a built-in map key when you do a gradient or buckets, which can be very helpful to show electoral numbers.
12. Additionally, you can change which columns of data will display when a district is clicked by going to "change info window."Note that you can create multiple maps from the same file, so if you wanted to show presidential result and then the projected outcome by party winner you could do so, while you can also duplicate a particular map. This is helpful for instance if you wanted to show something like racial demographics where one map is a gradient of the white percentage and another identically-positioned map is a gradient of the black percentage. I typically like to move my maps to the front, ahead of the "Rows" of data, so that when someone clicks the link it goes straight to the map (also note you can rename these).
13. When your map is finished, there are two ways you can share it. The first is through the standard link itself, while Google also allows embeds like I did above. Unfortunately though, Daily Kos does now allow regular diarists to embed maps like this, but it should work on other websites that use HTML. In general though, linking your map is good anyway because it is not restricted by the size of the embed window.
Note that when you are signed into Google and viewing the map you have created (or can edit), wherever you have last set the map position and zoom is the view that other users will see as a default when they open the map. Typically I will leave my map centered and if I want to move around on it I will just re-open the page in private browsing/incognito mode. On a related note, when you want to embed a map, you need to either zoom to the view that will allow it to fit in the embed frame or change that value in the html code it produces. So for the maps in this diary I zoomed out, produced the embed code, and then zoomed back in so that those who click the link to the full page will have a nice default view. Also note that the automatic legend works poorly with different zoom levels in embedded maps.
14. If you really want to get fancy, you can combine multiple states into a larger map as I have done here. To do so, open two completed shapefiles which have matching column headers in QGIS. Turn on editing on both, select all the features on one, copy them, then paste them into the other layer and voila, the map will be combined. Alternately, if you have several different layers you want to combine into one, you can put them into a single folder and do Vector>Data Management Tools>Merge Shapefiles to One, and select the folder option.
You can also easily substitute a new district for the particular district in the shapefile of a map you already created. So if I figure out a way of drawing the boundary between districts one and two that I like better, I can create a shapefile of just those two districts, copy the features, and paste them into the bigger shapefile once I've deleted the old versions. This is helpful for updating a map you have already published on Google, since all you would need to do to change the district shape is to copy the geometry coordinates from the new district's shapefile and replace the coordinates in the old one.
If you want to simply utilize the actual congressional districts for something like a race ratings map, etc., there is a handy site that has shapefiles for every national congressional map going back to the first Congress. I also have a 50-states shapefile in case you want to do statewide elections such as the senate or electoral college.
I hope this guide was clear enough for you to understand how to do this process. QGIS can be a little overwhelming at first if you have never used GIS software, but if you use it enough you will get the hang of it. If there's a function you don't understand, just Google the problem or search Stack Exchange for it and discussion of it will likely come up.
Feel free to ask any questions if there is something about these steps that needs clarifications and I look forward to seeing your maps.