Skip to content
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

spplot does not handle raster of 1 cell. #65

Closed
alaindanet opened this issue Nov 10, 2019 · 3 comments
Closed

spplot does not handle raster of 1 cell. #65

alaindanet opened this issue Nov 10, 2019 · 3 comments

Comments

@alaindanet
Copy link

Hi,
thank you very much for the package!

I would expect that sp::spplot() can plot a raster of size 1 if sp::plot() can do it.
It is not a big issue I guess, but it is annoying when testing/debugging functions with dummy datasets.

library('sp')
r <- raster::raster(nrows = 1, ncols = 1, xmn = 2, xmx = 4, ymn = 26, ymx = 28)
raster::values(r) <- rnorm(length(raster::values(r))) 

# Does not work:
spplot(r)
#> Error in apply(sapply(from@data, is.na), 1, function(x) !all(x)): dim(X) doit avoir un longueur positive
# Work: 
plot(r)

Created on 2019-11-10 by the reprex package (v0.3.0)

@edzer
Copy link
Owner

edzer commented Nov 10, 2019 via email

@alaindanet
Copy link
Author

Thanks. Unfortunately, it did not solve the problem

library('raster')
#> Le chargement a nécessité le package : sp

r <- raster::raster(nrows = 1, ncols = 1, xmn = 2, xmx = 4, ymn = 26, ymx = 28)
raster::values(r) <- rnorm(length(raster::values(r))) 

# Does not work:
spplot(r)
#> Error in apply(sapply(from@data, is.na), 1, function(x) !all(x)): dim(X) doit avoir un longueur positive
# Work: 
plot(r)

Created on 2019-11-10 by the reprex package (v0.3.0)

@edzer
Copy link
Owner

edzer commented Nov 10, 2019

Yes, this is a bug. Since it is a corner case and sp is in maintenance mode, I am not going to correct it. Thanks for reporting; PR will be accepted after someone tests it against all reverse dependencies.

@edzer edzer closed this as completed Nov 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants