R for GIS
This page is for the spatial R libraries and tools installed in the R environment in Puhti. Documentation for R in general is located on the r-env
page. Spatial libraries are included in all R versions in Puhti.
Usage
Loading the module
Load the general R module with
module load r-env
Installed spatial R libraries
- aws.s3 - for working with S3 storage, for example Allas. Example.
- CAST - functionality to run
caret
with spatial or spatial-temporal data - fasterize - a faster replacement for rasterize() from the
raster
package - FORTLS - processing of terrestrial laser scanning (TLS) point cloud data for forestry purposes
- gdalcubes - for working with multitemporal raster data cubes
- gdalUtils - wrappers for GDAL utilities
- geoR - geostatistical analysis including traditional, likelihood-based and Bayesian methods
- geosphere - spherical trigonometry for geographic coordinates (lat, lon)
- ggmap - map visualizations with
ggplot2
. As background map various online sources can be ued (e.g Google Maps and Stamen Maps). It includes tools also for geocoding and routing - gstat - spatial and spatio-temporal geostatistical modelling, prediction and simulation. Variogram modelling; simple, ordinary and universal point or block (co)kriging; spatio-temporal kriging; sequential Gaussian or indicator (co)simulation; variogram and variogram map plotting utility functions
- GWmodel - geographically-weighted models: GW summary statistics, GW principal components analysis, GW discriminant analysis and various forms of GW regression
- lidR - LiDAR data manipulation and visualization (for forestry applications), computation of metrics in area based approach, point filtering, artificial point reduction, classification from geographic data, normalization, individual tree segmentation and other manipulations
- lidRtRee - forest analysis with airborne laser scanning (LiDAR) data
- mapedit - interactive editing of sf objects
- maptools - tools for manipulating geographic data and interface wrappers for exchanging spatial objects with several other R packages
- mapview - quickly and conveniently create interactive visualisations of spatial data with or without background maps. Attributes of displayed features are fully queryable via pop-up windows
- ncdf4 - read, write and modify NetCDF-files
- ows4R - reading data from OGC APIs
- RandomFields - simulation and analysis of random fields
- raster - main package for raster data
- rgdal - bindings to GDAL and PROJ libraries, for basic data reading and writing
- rgeos - binding to GEOS library, for topology operations on geometries
- rlas - read and write 'las' and 'laz' file formats
- rstac - client library for Spatio-Temporal Asset Catalog (STAC)
- rTLS - process terrestrial laser scanning (TLS) point clouds
- Rsagacmd - for using SAGA GIS commands from R
- sen2r - find, download and process Sentinel-2 data
- sf - main package for vector data, bindings to GDAL, GEOS and PROJ libraries. Works with tidyverse packages. Similar functionality, but newer and better than sp
- sp - older main package for vector data
- spacetime - for working with spatio-temporal data
- spatial - for kriging and point pattern analysis
- spatstat - for analysing point patterns
- spdep - spatial dependence: weighting schemes, statistics and models
- stars - reading, manipulating, writing and plotting spatiotemporal arrays (raster and vector data cubes)
- terra - diverse methods for spatial data analysis, particularly raster data
- viridis - color maps for map plotting
You can also install your own additional libraries. Just follow the instructions in the main R page.
GDAL and SAGA GIS support
The r-env
module includes the following GDAL and SAGA GIS installations.
Module name (R version) | GDAL version | SAGA GIS version |
---|---|---|
r-env/4.2.1 | 3.5.1 | 8.2.2 |
Parallel computing
Some R packages like raster and spatial.tools include functions that support parallel computing. There is an example of using predict function from raster package in parallel among our examples.
Other than those, you have to parallelize your own R code which can be done with libraries including snow (see the documentation for the r-env module).
Interactive usage
It is possible to use RStudio with an interactive session.
Using Allas from R
You can use Allas from R with the package aws.s3. You can find CSC examples how to use it here.
It is also possible to read and write files from and to Allas or other cloud object storage directly with GDAL-based packages such as sf
and terra
. Please check our Using geospatial files directly from cloud, inc Allas tutorial for instructions and examples.
With large quantities of data in Allas, consider using virtual rasters.
License and acknowledgement
All packages are licensed under various free and open source licenses (FOSS), see the linked pages above for exact details. For finding out the correct citations for R and different R packages, you can type:
citation() # for citing R
citation("package") # for citing R packages
Please acknowledge CSC and Geoportti in your publications, it is important for project continuation and funding reports. As an example, you can write "The authors wish to thank CSC - IT Center for Science, Finland (urn:nbn:fi:research-infras-2016072531) and the Open Geospatial Information Infrastructure for Research (Geoportti, urn:nbn:fi:research-infras-2016072513) for computational resources and support".
References
- Examples for using R spatial packages for GIS in Puhti, CSC
- List of spatial R packages in CRAN
- Spatial Data Science, Edzer Pebesma, Roger Bivand
- Geocomputation with R, Robin Lovelace, Jakub Nowosad, Jannes Muenchow
- Spatial data science with R, Robert J. Hijmans
- Intro to GIS and Spatial analysis, Manuel Gimond
- Spatial Modelling for Data Scientists, Francisco Rowe, Dani Arribas-Bel
- Tutorial for geospatial R tools
- CSC course on spatial R, Marko Kallio
- Geographic Data Science with R: Visualizing and Analyzing Environmental Change, Michael C. Wimberly