plotkml栅格显示红色X而不是图像

时间:2017-06-09 10:22:34

标签: r kml raster

可以在此处下载光栅图像:

https://github.com/Alexvonrass/BS_Selection_tool/blob/master/data/msc_raster.RDS

我运行此代码:

r <- readRDS("msc_raster.RDS")
kml(r, colour = r@data@values, file='ms.kml') 

然后我收到这些警告(不确定它们是否与问题有关)

KML file opened for writing...
Writing to KML...
Closing  ms.kml
Warning messages:
1: In paths(show.paths = TRUE) :
  Could not locate GDAL! Install program and add it to the Windows registry. See http://www.gdal.org/ for more info.
2: In paths(show.paths = TRUE) :
  Could not locate SAGA GIS! Install program and add it to the Windows registry. See http://www.saga-gis.org/en/ for more info.

我得到一个kml文件,其中包含正确的图例,正确的光栅图像位置和大小,但不是实际图像,而是红色X:

http://imgur.com/a/Xzado

它会将所需的图像写入.png,但不会将其放入.kml中 我认为它与r写的.png图像的文件名有关,但我现在无法使它工作。

1 个答案:

答案 0 :(得分:1)

plotKML似乎搞砸了要显示的png的引用。它找不到它,因此是红色的X.

一个简单的解决方法是将参数raster_name添加到函数调用中:

kml(r,raster_name = 'layer.png', colour = r@data@values, file='ms.kml')