Skip to content

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-singularity 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-singularity

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
  • 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
  • gstat - functions for variogram modelling and kriging data
  • 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
  • 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
  • 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
  • RSAGA - for using SAGA GIS commands from R (no longer actively maintained)
  • Rsagacmd - for using SAGA GIS commands from R (actively maintained, supports newer SAGA GIS versions)
  • 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-singularity module includes the following GDAL and SAGA GIS installations.

Module name (R version) GDAL version SAGA GIS version
r-env-singularity/3.6.3 2.4.2 7.3.0
r-env-singularity/4.0.2 3.2.0 7.9.0
r-env-singularity/4.0.3 3.2.0 7.9.0
r-env-singularity/4.0.4 3.2.0 7.10.0
r-env-singularity/4.0.5 3.2.0 7.10.0

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-singularity 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 possible to use files directly from Allas with libraries like sf and raster. With large quantities of data in Allas, virtual rasters should be considered. More information on how to create and use virtual rasters can be found here.

Citation

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

In your publications please acknowledge also oGIIR and CSC, for example β€œThe authors wish to acknowledge for computational resources CSC – IT Center for Science, Finland (urn:nbn:fi:research-infras-2016072531) and the Open Geospatial Information Infrastructure for Research (oGIIR, urn:nbn:fi:research-infras-2016072513).”

References

Last edited Wed May 5 2021