1

I've been trying to do some raster image manipulation in R language using grid package. The problem is that I cannot retrive a return value from grid.raster function. When I do:

result <- grid.raster(inputData)

instead of "a rastergrob grob" (as specified in a documentation) I receive a NULL object.

I've double checked it with an example from the documentation:

redGradient <- matrix(hcl(0, 80, seq(50, 80, 10)), nrow=4, ncol=5)
grid.newpage()
result <- grid.raster(redGradient)

Still result is just a NULL object. Is R doing some return value interception here? If so, how can I get it?

4

1 回答 1

2

使用rasterGrob功能:

result <- rasterGrob(redGradient)

这两个函数共享一个文档页面,但是查看源代码,您可以看到grid.raster创建 grob 然后绘制它,返回grid.draw( NULL) 的值,而rasterGrob简单地返回 grob。

于 2013-10-15T20:10:05.020 回答