spex (version 0.7.1)

buffer_extent: Whole grain buffers

Description

Ensure a raster extent aligns to a clean divisor.

Usage

buffer_extent(e1, e2)

Arguments

e1

input extent

e2

grain size

Details

This function is used to generate extents that have tidy boundaries, i.e. extents that align to a clean whole number like "10000".

(We can't use the S4 group generic because raster has set that specifically for use with '+' and '-'.)

Examples

Run this code
# NOT RUN {
library(raster)
buffer_extent(extent(0.1, 2.2, 0, 3), 2)

p <- par(xpd = NA) 
plot(lux)
plot(extent(lux), lty = 2, add = TRUE, col = "grey")
plot(buffer_extent(lux, 0.1), add = TRUE)
abline(v = c(5.7, 6.6), h = c(49.4, 50.2))
title("boundaries on clean alignment to 0.1")
par(p)
# }

Run the code above in your browser using DataLab