-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ggRGB unable to plot masked image #118
Comments
Hey, unfortunately, I am not really able to reproduce the error. For me, already the crop call yields I recommend getting the last.rds from the Would that be a solution? |
I have edited the code to make the error reproducible. Please have a look. |
Interestingly, I still cant reporduce the following part of the error: Error in grid.Call.graphics(C_raster, x$raster, x$x, x$y, x$width, x$height, :
cannot allocate memory block of size 67108864 Tb Anyhow, you seem to be correct, I'll look into the error this week or next weekend. For now, just do not plot the RGB as a ggLayer, but as a base ggplot using the following snippet (also do not forget to set geom_raster = T): library(terra)
library(ggplot2)
library(RStoolbox)
lsat
plotRGB(lsat, r = 3, g = 2, b = 1, stretch = "hist")
# SpatVector as standalone object
m <- structure(
list(geom = "POLYGON ((620947.959184 -412745.345369, 621312.951334 -414249.11303, 623254.709576 -414526.507064, 623897.095761 -413154.136578, 621152.354788 -411767.166405, 620947.959184 -412745.345369))"),
class = "data.frame",
row.names = c(NA, -1L)
)
# To SpatVector with the right CRS
m <- vect(m$geom, crs = crs(lsat))
plot(m, add = TRUE, col = "red")
lsat.masked <- crop(lsat, m, mask = T)
plotRGB(lsat.masked, r = 3, g = 2, b = 1, stretch = "hist")
ggRGB(img = lsat.masked, r = 3, g = 2, b = 1, stretch = "hist", geom_raster = T) +
geom_whatever() |
Hi, soooo this isn't actually a bug. We are just missing When trying to return the library(terra)
library(ggplot2)
library(RStoolbox)
lsat
plotRGB(lsat, r = 3, g = 2, b = 1, stretch = "hist")
# SpatVector as standalone object
m <- structure(
list(geom = "POLYGON ((620947.959184 -412745.345369, 621312.951334 -414249.11303, 623254.709576 -414526.507064, 623897.095761 -413154.136578, 621152.354788 -411767.166405, 620947.959184 -412745.345369))"),
class = "data.frame",
row.names = c(NA, -1L)
)
# To SpatVector with the right CRS
m <- vect(m$geom, crs = crs(lsat))
plot(m, add = TRUE, col = "red")
lsat.masked <- crop(lsat, m, mask = T)
plotRGB(lsat.masked, r = 3, g = 2, b = 1, stretch = "hist")
ggplot() +
ggRGB(img = lsat.masked, r = 3, g = 2, b = 1, stretch = "hist", geom_raster = T, ggLayer = T) +
scale_fill_identity() If this does not work for you, please reopen this issue. Imma close now :) |
ggRGB
unable to plot the masked image. Here is a minimal, reproducible exampleIt returns the following error
The text was updated successfully, but these errors were encountered: