Reputation: 6796
I have R code as below. 1st plot()
and 1st plotRGB()
command work fine. I would like to split the images
in the second block of code plot()
works but plotRGB()
fails. How can I make plotRGB
work in that second case? My end goal is to get the cropped image in original colors
r <- raster(system.file("external/rlogo.grd", package="raster"))
r1 <- brick(system.file("external/rlogo.grd", package="raster"))
plot(r)
plotRGB(r1, interpolate = TRUE)
plot(r,xlim=c(0,50),ylim=c(0,50),legend=FALSE,axes=FALSE,frame.plot=F)
plotRGB(r1,xlim=c(0,50),ylim=c(0,50),legend=FALSE,axes=FALSE,frame.plot=F)
Upvotes: 1
Views: 689
Reputation: 47546
That is a bug, but it easy to work around it via the 'crop' function
r1 <- brick(system.file("external/rlogo.grd", package="raster"))
x <- crop(r1, extent(0,50,0,50))
plotRGB(x)
Upvotes: 2