mapview icon indicating copy to clipboard operation
mapview copied to clipboard

viewRGB() support for stars input

Open fdetsch opened this issue 5 years ago • 1 comments

viewRGB() works fine with Raster input, but does not support stars objects as of yet. Would you be willing to implement that?

data(
  "KiLi"
  , package = "Orcs"
)

## convert to stars
strs = stars::st_as_stars(
  KiLi
  , crs = 32737
)

mapview::viewRGB(strs, r = 1, b = 3)

currently fails with

Error in mapview::viewRGB(strs, r = 1, b = 3) : 'x' must be a Raster* object.

Converting to Raster solves the issue:

mapview::viewRGB(as(strs, "Raster"), r = 1, b = 3)

KiLi

Strange enough, plotting KiLi as regular 3-layered RasterStack directly with

mapview::viewRGB(KiLi, r = 1, b = 3)

gives

Error in CRS(projfrom) : no method for coercing this S4 class to a vector

, which I believe is a different matter.

fdetsch avatar Dec 21 '20 12:12 fdetsch

I came here to raise the exact same issue. Given that terra and/or stars seems to be replacing raster, it would be nice to have support for these formats.

vorpalvorpal avatar Dec 22 '22 02:12 vorpalvorpal