rdwd
rdwd copied to clipboard
replace raster with terra
terra
, the future replacement of the raster
package should be implemented where possible, as the usage of proj4 strings now throw warnings through rgdal. WKT is now recommended and terra
seems to do that internally just fine.
Maybe keep the raster argument with default FALSE and add terra argument.
Maybe make projectRasterDWD
dependant on input class.
fn <- "misc/localdata/16_DJF_grids_germany_seasonal_air_temp_mean_188216.asc"
r <- raster::raster(fn)
rt <- terra::rast(nrows=raster::nrow(r), ncols=raster::ncol(r), extent=r@extent)
terra::values(rt) <- raster::values(r)
terra::plot(rt)
library(terra)
terra::plot(rt) # only works after calling library...
pseas <- "+proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs"
ptar <- "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"
terra::crs(rt) <- pseas
rp <- terra::project(rt, ptar)
terra::plot(rp)
addBorders()