Tutor must be familiar using Rstudio(R markdown)
The world!
For today, I’ve given you a number of shapefiles associated with worldmaps, state maps of the US, and county maps of Massachusetts and the coronavirus. You can download the data here. I’d like you to take a gander and think about what you can do with them.
To start with, let’s take a look at the world.
<code><strong>library</strong>(sf) <strong>library</strong>(ggplot2) worldmap <- st_read(<span class="hljs-string">"./data/coronavirus_shapefiles/worldmap.shp"</span>)</code>
<code>## Reading layer `worldmap' from data source `/Users/jarrett.byrnes/Dropbox (Byrnes Lab)/Classes/Biol 355 Ugrad_Data_Science/Labs/data/coronavirus_shapefiles/worldmap.shp' using driver `ESRI Shapefile' ## Simple feature collection with 177 features and 63 fields ## geometry type: MULTIPOLYGON ## dimension: XY ## bbox: xmin: -180 ymin: -90 xmax: 180 ymax: 83.64513 ## epsg (SRID): 4326 ## proj4string: +proj=longlat +datum=WGS84 +no_defs</code>
<code>ggplot(worldmap) + geom_sf() + coord_sf()</code>
That’s a nice example workflow for loading and plotting one single shapefile. The shapefiles I have given you have multiple rows for dates, geospatial areas, and different case types (confirmed, death, recovered). You should be somewhat familiar with this alread.
Available Shapefiles
- worldmap.shp – A map of the world with country boundaries.
- us.shp – A map of the US with state boundaries.
- ma_county_maps.shp – A map of Massachusetts with county boundaries.
- coronavirus_points.shp – The coronavirus dataset with each lat/long as a POINT.
- coronavirus_polys.shp – The coronavirus dataset with each case in a country POLYGON.
- ma_counties_coronavirus.shp – The coronavirus dataset for Massachusetts with each case as a polygon in a MA county.
- usa_coronavirus_points.shp – All coronavirus data in the US represented as POINTS.
- usa_coronavirus_polygons – All coronavirus data in the US represented as POLYGONS. You have a number of available shapefiles for use. Here they are
Lab Exercises
With that in mind, I’d like you to –
- Plot the spatial distribution of coronavirus cases. Color by date.
- Show the distribution of mortality across the world by country using polygons.
- Within the US, show the total confirmed cases of coronavirus across the country by state. Feel free to use points or polygons here.
- Show the progression of conformed coronavirus in Massachusetts spatially over time using facets and dates.
- Take the map above you liked the most and reproject it! Do something cool and funky looking!


0 comments