Skip to main content Skip to navigation
CEREO mapping

Mapping with Shapefiles and Thiessen polygon generation

Today Tung Nguyen presented some advanced mapping techniques. Today’s presentation used the following packages and a function from Stackoverflow (http://stackoverflow.com/questions/12156475/combine-voronoi-polygons-and-maps). He also used the attached shapefiles: r_base_shapefile

Packages: “deldir”, “rgdal”, “sp”, “rgeos”, “maptools”, “gstat”, “mapview”, “ggplot2”, “ggmap”, “viridis”, “dplyr”

Tung showed us how he created polygons for individual catchments basins and then apply those polygons to a google maps basemap. In addition, we used ggplot2 to create differently sized symbols representing mean catchment size.

Script: more-mapping-thiessen-polygons-and-google-basemaps

Simple Mapping in R

Today we discussed using the “maps” package and the “ggplot2” package to make simple maps in R.

Our test dataset is from the “rgbif” data package which makes use of publicly available data (see the “getting data” Topic). To deal with some of the georeferenced data we made use of the “dismo” package .

We made a basic map using ‘maps’:

maps-map

And then took the same data and mapped it using ggplot2:

ggplot-map

Because maps limits its field of view to the “states” basemap, whereas ggplot2 does not, we weren’t able to see this spurious detection way out in the middle of the ocean. Now that we see it, we used subset() to remove it and then made a fancy WSU themed cougar map using ggplot2:

fancy-subset-ggplot-map

The Script is here: simple-mapping