R/ra_resolution.R

Defines functions ra_resolution

Documented in ra_resolution

#' Function to get the resolution of a raster object.
#' 
#' @param ra Raster object.
#' 
#' @author Stuart K. Grange
#' 
#' @return Tibble.
#' 
#' @export
ra_resolution <- function(ra) {
  
  # Check input
  stopifnot(is.ra(ra))
  
  # Get resolution
  resolution <- raster::res(ra)
  
  # Is the projection system metric?
  metric <- ra %>% 
    sp_projection() %>% 
    stringr::str_detect("units=m")
  
  # Build tibble return
  df <- tibble(
    x = resolution[1], 
    y = resolution[2],
    metric = metric
  )
  
  return(df)
  
}
skgrange/gissr documentation built on Feb. 24, 2024, 2:55 p.m.