Introduction to Reproducible Geospatial Analysis and Figures in R: A Tutorial Article
Abstract
:1. Introduction
2. The Basics of GIS and Geospatial Analysis
2.1. Geospatial Data Types and Formats
2.2. Coordinate Reference System(CRS)
2.3. Workflow
3. Example of Common Map Types
3.1. Scatter Map
3.2. Choropleth Maps
3.3. Hexbin Map
3.4. Bubble Map
3.5. Faceted Map
3.6. Insets
4. Conclusions
Supplementary Materials
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
Abbreviations
GIS | Geospatial Information System |
CRS | Coordinate Reference System |
SOC | Soil Organic Carbon |
NUTS | Nomenclature of Territorial Units for Statistics |
1 | Technical documentation on this function is available in the vignette at https://cran.r-project.org/web/packages/ggplot2/ggplot2.pdf (accessed on 20 March 2024) |
2 | Technical documentation on this function is available in the vignette at https://cran.r-project.org/web/packages/ggplot2/ggplot2.pdf (accessed on 20 March 2024) |
3 | https://dieghernan.github.io/202203_insetmaps/ (accessed on 20 March 2024) |
4 | https://upgo.lab.mcgill.ca/2019/12/13/making-beautiful-maps/ (accessed on 20 March 2024) |
5 | https://r-spatial.org/r/2018/10/25/ggplot2-sf-3.html (accessed on 20 March 2024) |
6 | https://r-spatial.org/r/2018/10/25/ggplot2-sf-3.html (accessed on 20 March 2024) |
References
- R Core Team. R: A Language and Environment for Statistical Computing; R Foundation for Statistical Computing: Vienna, Austria, 2023. [Google Scholar]
- Curtis, M.L.; Nunez, G.H. Trends in Statistical Analysis Software Use for Horticulture Research between 2005 and 2020. HortTechnology 2022, 32, 356–358. [Google Scholar] [CrossRef]
- Masuadi, E.; Mohamud, M.; Almutairi, M.; Alsunaidi, A.; Alswayed, A.K.; Aldhafeeri, O.F. Trends in the Usage of Statistical Software and Their Associated Study Designs in Health Sciences Research: A Bibliometric Analysis. Cureus 2021, 13, e12639. [Google Scholar] [CrossRef] [PubMed]
- Xie, Y. knitr: A Comprehensive Tool for Reproducible Research in R. In Implementing Reproducible Computational Research; Stodden, V., Leisch, F., Peng, R.D., Eds.; Chapman & Hall/CRC: Boca Raton, FL, USA, 2014. [Google Scholar]
- Xie, Y. Dynamic Documents with R and knitr, 2nd ed.; Chapman & Hall/CRC: Boca Raton, FL, USA, 2015. [Google Scholar]
- Xie, Y. knitr: A General-Purpose Package for Dynamic Report Generation in R; R Package Version 1.44; R Foundation for Statistical Computing: Vienna, Austria, 2023; Available online: https://rdrr.io/cran/knitr/ (accessed on 20 March 2024).
- Xie, Y.; Allaire, J.; Grolemund, G. R Markdown: The Definitive Guide; Chapman & Hall/CRC: Boca Raton, FL, USA, 2018. [Google Scholar]
- Xie, Y.; Dervieux, C.; Riederer, E. R Markdown Cookbook; Chapman & Hall/CRC: Boca Raton, FL, USA, 2020. [Google Scholar]
- Allaire, J.; Xie, Y.; Dervieux, C.; McPherson, J.; Luraschi, J.; Ushey, K.; Atkins, A.; Wickham, H.; Cheng, J.; Chang, W.; et al. rmarkdown: Dynamic Documents for R; R Package Version 2.25.; R Foundation for Statistical Computing: Vienna, Austria, 2023. [Google Scholar]
- Xie, Y. bookdown: Authoring Books and Technical Documents with R Markdown; Chapman & Hall/CRC: Boca Raton, FL, USA, 2016. [Google Scholar]
- Xie, Y. bookdown: Authoring Books and Technical Documents with R Markdown; R Package Version 0.38; R Foundation for Statistical Computing: Vienna, Austria, 2024. [Google Scholar]
- Puetz, S.J.; Condie, K.C.; Sundell, K.; Roberts, N.M.; Spencer, C.J.; Boulila, S.; Cheng, Q. The replication crisis and its relevance to Earth Science studies: Case studies and recommendations. Geosci. Front. 2024, 15, 101821. [Google Scholar] [CrossRef]
- Hicks, D.J. Open science, the replication crisis, and environmental public health. Account. Res. 2021, 30, 34–62. [Google Scholar] [CrossRef] [PubMed]
- Caprarelli, G.; Sedora, B.; Ricci, M.; Stall, S.; Giampoala, M. Notebooks Now! The Future of Reproducible Research. Earth Space Sci. 2023, 10, e2023EA003458. [Google Scholar] [CrossRef]
- Holmes, D.T.; Mobini, M.; McCudden, C.R. Reproducible manuscript preparation with RMarkdown application to JMSACL and other Elsevier Journals. J. Mass Spectrom. Adv. Clin. Lab 2021, 22, 8–16. [Google Scholar] [CrossRef]
- Bauer, P.C.; Landesvatter, C. Writing a Reproducible Paper with R Markdown and Pagedown. 2021. Available online: https://osf.io/preprints/osf/k8jhx (accessed on 20 March 2024). [CrossRef]
- Slater, L.J.; Thirel, G.; Harrigan, S.; Delaigue, O.; Hurley, A.; Khouakhi, A.; Prosdocimi, I.; Vitolo, C.; Smith, K. Using R in hydrology: A review of recent developments and future directions. Hydrol. Earth Syst. Sci. 2019, 23, 2939–2963. [Google Scholar] [CrossRef]
- Giraud, T.; Lambert, N. Reproducible Cartography. In Advances in Cartography and GIScience; Lecture Notes in Geoinformation and, Cartography; Peterson, M., Ed.; Springer: Cham, Switzerland, 2017; pp. 173–183. [Google Scholar] [CrossRef]
- Hijmans, R.J. terra: Spatial Data Analysis; R Package Version 1.7–71; R Foundation for Statistical Computing: Vienna, Austria, 2024. [Google Scholar]
- Pebesma, E. Simple Features for R: Standardized Support for Spatial Vector Data. R J. 2018, 10, 439–446. [Google Scholar] [CrossRef]
- Dunnington, D.; Pebesma, E.; Rubak, E. s2: Spherical Geometry Operators Using the S2 Geometry Library. 2024. R Package 57 Version 1.1.6. Available online: https://github.com/r-spatial/s2 (accessed on 20 March 2024).
- GEOS Contributors. GEOS Coordinate Transformation Software Library; Open Source Geospatial Foundation: Beaverton, OR, USA, 2021. [Google Scholar]
- GDAL/OGR Contributors. GDAL/OGR Geospatial Data Abstraction Software LIBRARY; Open Source Geospatial Foundation: Beaverton, OR, USA, 2020. [Google Scholar]
- PROJ Contributors. PROJ Coordinate Transformation Software Library; Open Source Geospatial Foundation: Beaverton, OR, USA, 2022. [Google Scholar] [CrossRef]
- Wickham, H. ggplot2: Elegant Graphics for Data Analysis; Springer: New York, NY, USA, 2016. [Google Scholar]
- Dunnington, D. ggspatial: Spatial Data Framework for ggplot2; R Package Version 1.1.9; R Foundation for Statistical Computing: Vienna, Austria, 2023. [Google Scholar]
- Tennekes, M. tmap: Thematic Maps in R. J. Stat. Softw. 2018, 84, 1–39. [Google Scholar] [CrossRef]
- Cheng, J.; Schloerke, B.; Karambelkar, B.; Xie, Y. leaflet: Create Interactive Web Maps with the JavaScript ‘Leaflet’ Library; R Package Version 2.2.1; R Foundation for Statistical Computing: Vienna, Austria, 2023. [Google Scholar]
- Kahle, D.; Wickham, H. ggmap: Spatial Visualization with ggplot2. R J. 2013, 5, 144–161. [Google Scholar] [CrossRef]
- Cooley, D. mapdeck: Interactive Maps Using ‘Mapbox GL JS’ and ‘Deck.gl’; R Package Version 0.3.5; R Foundation for Statistical Computing: Vienna, Austria, 2024. [Google Scholar]
- Appelhans, T.; Detsch, F.; Reudenbach, C.; Woellauer, S. mapview: Interactive Viewing of Spatial Data in R; R Package Version 2.11.2; R Foundation for Statistical Computing: Vienna, Austria, 2023. [Google Scholar]
- Pebesma, E.; Bivand, R. Spatial Data Science with Applications in R; Chapman & Hall/CRC The R Series; Chapman & Hall/CRC: Boca Raton, FL, USA; Philadelphia, PA, USA, 2023. [Google Scholar]
- Lott, R. Geographic Information—Well-Known Text Representation of Coordinate Reference Systems; Technical Report 18-010r7; Open Geospatial Consortium: Arlington, VA, USA, 2019. [Google Scholar]
- Butler, H.; Daly, M.; Doyle, A.; Gillies, S.; Schaub, T.; Hagen, S. The GeoJSON Format. RFC 7946. 2016. Available online: https://www.rfc-editor.org/info/rfc7946 (accessed on 20 March 2024). [CrossRef]
- Daisey, P.; Yutzler, J. OGC® GeoPackage Encoding Standard; Technical Report OGC 12-128r19; Open Geospatial Consortium: Arlington, VA, USA, 2024. [Google Scholar]
- Devys, E.; Habermann, T.; Heazel, C.; Lott, R.; Even, R. OGC GeoTIFF Standard; Technical Report 19-008r4; Open Geospatial Consortium: Arlington, VA, USA, 2019. [Google Scholar]
- Hijmans, R.J. raster: Geographic Data Analysis and Modeling; R Package Version 3.6-26; R Foundation for Statistical Computing: Vienna, Austria, 2023. [Google Scholar]
- Schauberger, P.; Walker, A. openxlsx: Read, Write and Edit xlsx Files; R Package Version 4.2.5.2; R Foundation for Statistical Computing: Vienna, Austria, 2023. [Google Scholar]
- Pons, X.; Masó, J. A comprehensive open package format for preservation and distribution of geospatial data and metadata. Comput. Geosci. 2016, 97, 89–97. [Google Scholar] [CrossRef]
- Lovelace, R.; Nowosad, J.; Muenchow, J. Geocomputation with R; CRC Press: Boca Raton, FL, USA, 2020. [Google Scholar]
- International Organization for Standardization. ISO 19162 Geographic Information—Well-Known Text Representation of Coordinate Reference Systems; Technical Report ISO 19162:2019; International Organization for Standardization: Geneva, Switzerland, 2019. [Google Scholar]
- Massicotte, P.; South, A. rnaturalearth: World Map Data from Natural Earth, R package version 1.0.1; R Foundation for Statistical Computing: Vienna, Austria, 2023. [Google Scholar]
- South, A.; Michael, S.; Massicotte, P. rnaturalearthdata: World Vector Map Data from Natural Earth Used in ‘rnaturalearth’, R package version 1.0.0; R Foundation for Statistical Computing: Vienna, Austria, 2024. [Google Scholar]
- Hernangómez, D. giscoR: Download Map Data from GISCO API—Eurostat. 2024. Available online: https://zenodo.org/records/10885303 (accessed on 20 March 2024). [CrossRef]
- Hijmans, R.J.; Barbosa, M.; Ghosh, A.; Mandel, A. geodata: Download Geographic Data; R Package Version 0.5-9; R Foundation for Statistical Computing: Vienna, Austria, 2023. [Google Scholar]
- Wilkinson, L. The Grammar of Graphics, 2nd ed.; Statistics and Computing; Springer: New York, NY, USA, 2005. [Google Scholar]
- Oyana, T.J. Spatial Analysis with R: Statistics, Visualization, and Computational Methods; CRC Press: Boca Raton, FL, USA, 2020. [Google Scholar] [CrossRef]
- Moraga, P.; Baker, L. rspatialdata: A collection of data sources and tutorials on downloading and visualising spatial data using R. F1000Research 2022, 11, 770. [Google Scholar] [CrossRef] [PubMed]
- Poeplau, C.; Don, A.; Flessa, H. Erste Bodenzustandserhebung Landwirtschaft—Kerndatensatz. 2020. Available online: https://www.openagrar.de/receive/openagrar_mods_00054877 (accessed on 20 March 2024). [CrossRef]
- Wickham, H.; François, R.; Henry, L.; Müller, K.; Vaughan, D. dplyr: A Grammar of Data Manipulation; R Package Version 1.1.3; R Foundation for Statistical Computing: Vienna, Austria, 2023. [Google Scholar]
- Garnier, S.; Ross, N.; Rudis, R.; Camargo, P.A.; Sciaini, M.; Scherer, C. viridis(Lite)—Colorblind-Friendly Color Maps for R. 2023. Viridis Package Version 0.6.4. Available online: https://sjmgarnier.github.io/viridis/ (accessed on 20 March 2024). [CrossRef]
- Wickham, H.; Seidel, D. scales: Scale Functions for Visualization; R Package Version 1.2.1; R Foundation for Statistical Computing: Vienna, Austria, 2022. [Google Scholar]
- Lehner, B.; Grill, G. Global river hydrography and network routing: Baseline data and new approaches to study the world’s large river systems. Hydrol. Process. 2013, 27, 2171–2186. [Google Scholar] [CrossRef]
- Pebesma, E.; Mailund, T.; Hiebert, J. Measurement Units in R. R J. 2016, 8, 486–494. [Google Scholar] [CrossRef]
- Barnes, R.; Sahr, K. dggridR: Discrete Global Grids; R Package Version 3.0.0; R Foundation for Statistical Computing: Vienna, Austria, 2023. [Google Scholar]
- Lowe, D.; Gledson, A.; Topping, D.; Jay, C.; Reani, M. Britain Breathing 2016–2019 Air Quality and Meteorological Dataset, 2021. Available online: https://zenodo.org/records/5118563 (accessed on 20 March 2024). [CrossRef]
- Reani, M.; Lowe, D.; Gledson, A.; Topping, D.; Jay, C. UK daily meteorology, air quality, and pollen measurements for 2016–2019, with estimates for missing data. Sci. Data 2022, 9, 43. [Google Scholar] [CrossRef] [PubMed]
- Pebesma, E.J.; Bivand, R. Classes and methods for spatial data in R. R News 2005, 5, 9–13. [Google Scholar]
- Wilke, C.O. cowplot: Streamlined Plot Theme and Plot Annotations for ‘ggplot2’; R Package Version 1.1.3; R Foundation for Statistical Computing: Vienna, Austria, 2024. [Google Scholar]
Common Designation | File Extension(s) | Type | Normative Reference |
---|---|---|---|
shapefile | .shp, .shx, .dbf... | vector | [33] |
geoJSON | .geojson | vector | [34] |
geopackage | .gpkg | vector and raster | [35] |
geoTIFF | .tif, .tiff | raster | [36] |
Common Designation | Type | EPSG Code | Unit | Main Application |
---|---|---|---|---|
World Geodetic System 1984 (WGS84) | Geodetic | 4326 | degree | Global Positioning System (GPS) |
Pseudo-Mercator (web Mercator) | Projected | 3857 | metre | Web services |
Europe Lambert Equal Area (ETRS89/LAEA Europe) | Projected | 3035 | metre | Europe |
NAD83 | Projected | 4269 | degree | North America |
SIRGAS 2000/UTM zone 16N | Projected | 31970 | metre | Latin America |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Maesen, P.; Salingros, E. Introduction to Reproducible Geospatial Analysis and Figures in R: A Tutorial Article. Data 2024, 9, 58. https://doi.org/10.3390/data9040058
Maesen P, Salingros E. Introduction to Reproducible Geospatial Analysis and Figures in R: A Tutorial Article. Data. 2024; 9(4):58. https://doi.org/10.3390/data9040058
Chicago/Turabian StyleMaesen, Philippe, and Edouard Salingros. 2024. "Introduction to Reproducible Geospatial Analysis and Figures in R: A Tutorial Article" Data 9, no. 4: 58. https://doi.org/10.3390/data9040058
APA StyleMaesen, P., & Salingros, E. (2024). Introduction to Reproducible Geospatial Analysis and Figures in R: A Tutorial Article. Data, 9(4), 58. https://doi.org/10.3390/data9040058