Skip to content

binary raster plots with more than 2 colors #461

@jamiemkass

Description

@jamiemkass

When plotting a binary raster with addRasterImage(), even when the parameter "colors" is set to two colors, the plotted raster shows more than two colors. It seems that it's interpolating color values, even though this is not desired with a binary raster. Zoom in on the example below to see. If there's a way to fix this, please let me know.

v <- sample(c(0,1), 40000, replace = TRUE)
x <- raster::raster(nrows=160,ncols=250,xmn=-120,xmx=-80,ymn=15,ymx=40,vals=v)
m <- leaflet() %>% setView(-100, 25, zoom = 3) %>% addProviderTiles('Esri.WorldTopoMap')
m %>% addRasterImage(x, colors = c('red','blue'))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions