Can color palette be specified for rasterImage?

余生颓废 提交于 2019-12-13 04:35:45

问题


Title says it all, pretty much. So far as I can tell, trying to pass a simple color palette by using the col argument, e.g., rasterImage(mydata,xleft=1,ybottom=1,xright=2,ytop=2,col=grey(0:4095/4096)) fails. What's more confusing is that the default palette seems to depend on the class of mydata .

If I have a matrix, rasterImage(as.raster(mymatrix), {etc} plots in grayscale, while using a RasterLayer object, rasterImage(as.raster(myRaster),{etc} plots in a topo color set.

Any suggestions for alternative (fast) tools to plot large images gratefully accepted.


回答1:


I think just using useRaster=TRUE inside the basic graphics:image function is fine.

This works, and very quickly (as opposed to not rasterizing a large matrix), with a matrix or a RasterLayer object:

image(mydata, useRaster=TRUE, col={whatever})

I should have tried that before going off into wrapper functions.



来源:https://stackoverflow.com/questions/18835412/can-color-palette-be-specified-for-rasterimage

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!