GEOG 863
GIS Mashups for Geospatial Professionals

Mapping the 2012 Election

PrintPrint

The scenario for this lesson's optional assignment is to map the results of the 2012 presidential election at the county level for a state of your choice. You can use the classification scheme I used in my voter registration map or come up with your own. Here are the data you'll need to complete the project:

Note that the data for some states appear to be unreliable (e.g., Colorado, Utah, Wyoming). The data were downloaded from The Guardian in the UK, which unfortunately was the only place I could find free nationwide county-level results. Be sure the state you select passes the "smell" test.

Here's a basic outline of the major steps to complete:

  1. In ArcMap, use the Mashup toolbox to export a CSV file of the county polygon coordinates for your selected state.
  2. Import the coordinate data and election data into a new Access database.
  3. Examine the coordinate and election data and develop a plan for how you will store the data in MySQL. Be sure to identify key fields that can be used to associate the election information with the county geometries. (The FIPS codes in the election data don't match those in the counties shapefile because they lack the two-digit state code. You'll need to work out how to fix this.)
  4. Create the tables you envisioned in the previous step in your MySQL database using either phpMyAdmin or the MySQL Workbench.
  5. You should already have an ODBC data source associated with your MySQL database after completing the lesson.
  6. In your Access database, use the ODBC data source to add links to the MySQL tables you created.
  7. Build an Append query to add the coordinate data to your MySQL table.
  8. Build another Append query to add the election data to your MySQL table.
  9. Write a PHP script that retrieves the data required for your mashup and output the data in XML format. You may find it helpful to use the Access query GUI to generate the necessary SQL. Important notes:
  10. Build a web page containing JavaScript that reads the data outputted by your PHP script, creates polygons from the coordinate data and symbolizes the polygons based on the leading vote-getter in each county. Because of the same-domain restriction of the XMLHttpRequest object, you'll need to upload your page to your special php folder and open it using the phpdb.aset server for it to be able to read the data outputted by your PHP script (i.e., enter a URL like https://phpdb.aset.psu.edu/phpjed124/candidate_cities.html).
  11. Add a sidebar that lists the vote percentages for each candidate in each county.

If this election brings up bad memories for you, you're welcome to map a different election. You may also feel free to map the election results at the voting district level rather than at the county level.

Note

When selecting a state/county to map, beware of multi-part and donut polygons. These types of polygons require a different kind of storage in the database, different methods of retrieval from the database and different methods for turning them into Google Maps Polygon objects.

If you're very comfortable with the material from this lesson, you may want to try mapping a place that has some of these special polygons for an extra challenge. Otherwise, I'd recommend sticking with a place that's comprised of all simple polygons. If you're unsure whether your place of interest includes any special polygons, go ahead and export its coordinates to CSV. The tool's dialog box will warn you if any were encountered.

Deliverables

This project is optional and is not graded. However, it can be submitted to the instructor for feedback and/or to earn up to 5 points added to your overall course grade (on a 100-point scale).

  1. Post the map with data extracted from your MySQL database along with a clickable sidebar listing selected attribute information to your e-portfolio.
  2. Below the map, include some reflection on what you learned from the lesson and/or any concepts that you found to be confusing (minimum 200 words).