Skip to content

Repository files navigation

Week 3 - Geocoding and Simple Features

US Election Map

County-level election results

Resources

Assignment (optional)

Use ScapeToad to create a county-level election cartogram, with the areas scaled by the number of votes.

Due: 6-Feb-2018 before the start of class (optional)

US Election Cartogram

2016 U.S. presidential election cartogram

Description

Begin by exporting the election map we made in class, either the simple red-blue map or the one that scales by vote margin. Remember to transform the coordinates to WGS 84 (crs code 4326) before exporting.

st_transform(st_as_sf(elecjoin),crs = 4326) %>%
  st_write("election-map.shp", driver = "ESRI Shapefile")

Download ScapeToad, a simple application for making cartograms. There is no installation required. Just download the .zip, unpack the contents, and run the ScapeToad.exe executable.

ScapeToad is very easy to use. Just import the shapefile layer, press the Create Cartogram button, and follow the instructions.

  • Section 1: skip
  • Section 2: "Spatial coverage" = the shapefile you just imported
  • Section 3: "Cartogram attribute" = total votes ("ttl_vts") / "Attribute type" = Mass
  • Section 4: skip
  • Section 5: you can refine the quality of the transformation here, or just use the default settings

Once ScapeToad finishes, export the transformed cartogram. Load it into R using "st_read()" and set the CRS to WGS 84.

cartogram <- st_read('election-cartogram.shp', stringsAsFactors = FALSE)
st_crs(cartogram) = 4326

Now you can plot it as you did the original election map.

About

Geocoding, SF, choosing colors

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages