buffer_extent: Whole grain buffers

Description Usage Arguments Details Examples

View source: R/buffer_extent.R

Description

Ensure a raster extent aligns to a clean divisor.

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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)

spex documentation built on July 2, 2020, 2:22 a.m.