7.9 Exercises

  • List and describe three types of vector, raster, and geodatabase formats.

  • Name at least two differences between read_sf() and the more well-known function st_read().

  • Read the cycle_hire_xy.csv file from the spData package as a spatial object (Hint: it is located in the misc\ folder).What is a geometry type of the loaded object?

  • Download the borders of Germany using rnaturalearth, and create a new object called germany_borders.Write this new object to a file of the GeoPackage format.

  • Download the global monthly minimum temperature with a spatial resolution of five minutes using the raster package.Extract the June values, and save them to a file named tmin_june.tif file (hint: use raster::subset()).

  • Create a static map of Germany’s borders, and save it to a PNG file.

  • Create an interactive map using data from the cycle_hire_xy.csv file.Export this map to a file called cycle_hire.html.

References

Padgham, Mark, Bob Rudis, Robin Lovelace, and Maëlle Salmon. 2018. Osmdata: Import ’Openstreetmap’ Data as Simple Features or Spatial Objects. https://CRAN.R-project.org/package=osmdata.

Nolan, Deborah, and Duncan Temple Lang. 2014. XML and Web Technologies for Data Sciences with R. Use R! New York, NY: Springer.

Coppock, J Terry, and David W Rhind. 1991. “The History of GIS.” Geographical Information Systems: Principles and Applications, Vol. 1. 1 (1): 21–43.


  • For more information on data import with R packages, see Sections 5.5 and 5.6 of Gillespie and Lovelace (2016).

  • To filter features on the server before downloading them, the argument cql_filter can be used. Adding cql_filter = URLencode("F_CODE= '27'") to the command, for example, would instruct the server to only return the feature with values in the F_CODE column equal to 27.

  • To learn more about ESRI Shapefile limitations and possible alternative file formats, visit http://switchfromshapefile.org/.

  • A list of supported vector formats and options can be found at http://gdal.org/ogr_formats.html.

  • Using INT4U is not recommended as R does not support 32-bit unsigned integers.