Geographic Information Systems Asked on January 30, 2021
My existing code (see below) only reads and rotates one band but I want all 360 of my bands to rotate.
library(raster)
your_raster <- raster("path/to/raster.tif")
rotated_raster <- rotate(your_raster)
If you want to load a multi-band raster up, don't use raster()
function, use brick()
or stack()
instead. raster()
only opens single-band rasters, even from a multi-band raster (you can set the band you want to open).
Rotate works with multi-band rasters, so you'll be fine after opening the file:
r <- raster(nrow=18, ncol=36)
m <- matrix(1:ncell(r), nrow=18)
values(r) <- as.vector(t(m))
extent(r) <- extent(0, 360, -90, 90)
s <- stack(r,r,r)
rr <- rotate(s)
plot(s)
plot(rr)
Use write.raster(rotated_raster,'path_/to/file.tif')
then for saving the file in your computer.
Answered by aldo_tapia on January 30, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP