library(rmarkdown)
system.time(render("use_spCEH.Rmd", output_file = "use_spCEH.html"))

spCEH is an attempt to gather together some common functions and spatial data from CEH Edinburgh. The idea is to standardise where possible such things as UK coastline data, topography data, raster grids for the UK (& Scotland, ...). We share these in an easily accessible and updateable way by building them into an R package on GitHub.

Data

So far, data sets include:

Functions

So far, the package includes functions for:

Planned additions

Data

Functions

Examples

Install and load

# if not already installed:
library(devtools)
install_github("NERC-CEH/spCEH")
library(spCEH)
# source('./../R/spCEH.R')
# library(sf)
# library(terra)
devtools::load_all()

getSpatRasterTemplate

Generate a raster grid covering the UK domain at 5-km resolution:

r <- getSpatRasterTemplate(domain = "UK", res = 5000, proj = 'OSGB')
r

maskByCountry

Mask out cells which are not in England or Wales:

plot(st_geometry(spgdf_uk))
# or
plot(st_geometry(sfdf_uk))
r <- getSpatRasterTemplate(domain = "UK", res = 10000, proj = 'OSGB')
r <- setValues(r, 1) # add some dummy values to plot
r
r_masked <- maskByCountry(r, c("England", "Wales"))
plot(st_geometry(spgdf_uk))
plot(r_masked == 1, add = TRUE)

Load some data

Data sets included in the package are loaded into memory when needed (LazyData):

r_alt <- get_r_alt()  # and behold, it appears
plot(r_alt)

You can enable figure captions by fig_caption: yes in YAML:

output:
  rmarkdown::html_vignette:
    fig_caption: yes

Then you can use the chunk option fig.cap = "Your figure caption." in knitr.



NERC-CEH/spCEH documentation built on June 12, 2024, 2:45 p.m.