reextent: A function to alter the extent of rasters

View source: R/reextent_function.R

reextentR Documentation

A function to alter the extent of rasters

Description

This function shifts the extent of a raster from -180:180 to 0:360 and vice versa

Usage

reextent(ras, method)

Arguments

ras

Raster object to shift the extent

method

Numerical value to indicate direction of extent change. '1' shifts from -180:180 to 0:360. '2' shifts from 0:360 to -180:180.

Value

Shifted raster

Examples

### Create Test data
r <- raster::raster(vals = c(rep(1:360,length.out=64800/2),rep(1:360,length.out=64800/2)))
plot(r)
# convert r from -180:180 to 0:360
out <- reextent(r, method = 1)
plot(out)
# convert back to -180:180
out2 <- reextent(out, method = 2)
plot(out2)


Louismp1223/LMP3 documentation built on June 29, 2022, 5:11 p.m.