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 in the r-env-singularity page (or the r-env page for R 3.6.1).


Currently supported R versions for spatial libraries:

  • 3.6.3 (r-env-singularity module)
  • 3.6.1 (r-env module)


Loading the module

You can load the general R module with

module load r-env-singularity
# (or module load r-env)

Installed spatial R libraries

  • aws.s3 - for working with S3 storage, for example Allas. Example.
  • fasterize - a faster replacement for rasterize() from the 'raster' package
  • geoR - geostatistical analysis including traditional, likelihood-based and Bayesian methods
  • geoRglm - functions for inference in generalised linear spatial models, extension to the geoR package
  • 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
  • mapedit - interactive editing of sf objects
  • maptools
  • 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
  • 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
  • spatial.tools - to enhance the core functionality of the package "raster", including a parallel processing engine for use with rasters
  • spdep - spatial dependence: weighting schemes, statistics and models
  • spatstat - for analysing point patterns
  • viridis - color maps for map plotting

You can also install your own additional libraries. Just follow the instructions in the main R page.

r-env-singularity also loads:

r-env loads GDAL 2.4.2 and its commandline tools, and Saga-GIS 7.2.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 module).

Interactive usage

It is possible to use RStudio with an interactive batch job on Puhti:

  • r-env with RStudio desktop using NoMachine
  • r-env-singularity with RStudio Server, connecting to it from your local browser with SSH tunnel.

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


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).”