Skip to content

Mahti has expanded its capabilities with a new small partition with core-based allocation and fast local NVMe storage! Click here for details.

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
  • geodata - access to climate, crops, elevation, land use, soil, species occurrence, accessibility, administrative boundaries and other data.
  • geofi - download geospatial data on municipalities, zipcodes and population and statistical grids from Statistics Finland
  • 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
  • ggspatial - for map plotting
  • 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
  • [igraph]
  • 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. Example
  • 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
  • raster - main package for raster data
  • RCSF - Cloth Simulation Filter (CSF) is an LiDAR ground points filtering algorithm
  • 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
  • spatialreg - for spatial cross-sectional models
  • 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)
  • s2 - for geometric calculations on the sphere
  • terra - diverse methods for spatial data analysis, particularly raster data
  • tmap - for thematic maps

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 also GDAL and SAGA GIS.

Parallel computing

Some R packages like raster, terra and lidR include functions that support parallel computing. There is an example of using predict function from raster package in parallel among our examples.

For many other GIS packages you have to parallelize the code yourself. It can be done with several libraries, including future. See Parallel jobs using R tutorial for further information.

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