我正在尝试从栅格中获取数据并将其推送为 KML 格式,以便获得一系列网格多边形。
查看网络上的示例,似乎要走的路是使用grid2poly
with plotKML
。不幸的是,我遇到了一个似乎可以解除阻止的错误。
library(dismo)
require(plotKML)
library(rgdal)
tmin <- getData("worldclim", var = "tmin", res = 10) # this will download
# global data on minimum temperature at 10' resolution
tmin1 <- raster(paste(getwd(), "/wc10/tmin1.bil", sep = "")) # Tmin for January
newext <- c(-1, 1, 40, 43.5)
tmin1.c <- crop(tmin1, newext)
plot(tmin1.c)
tmin1.c # look at the info
head(tmin1.c,5)
tminvals <- rasterToPoints(tmin1.c)
tminvals # look at the info
head(tminvals,5)
str(tminvals)
###########################
#Everything works down to here
###########################
library(sp)
coordinates(tminvals) <- ~x+y
gridded(tminvals) <- TRUE
proj4string(tminvals) <- CRS("+proj=longlat +datum=WGS84")
data(SAGA_pal)
dem_poly <- grid2poly(tminvals, "tmin1", method = "sp")
## visualize the data in Google Earth:
kml(dem_poly, colour_scale = SAGA_pal[[1]], colour = tmin1, kmz = TRUE)
我收到如下所示的所有行的错误coordinates(tminvals) <- ~x+y
:
从(函数(类,fdef,mtable)中的错误:无法找到函数'坐标<-'签名'“矩阵”'的继承方法</p>
我不明白我做错了什么。当我查看数据集时tminvals
,它的内容看起来与原始示例数据非常相似eberg_grid
。