我正在忙着开发一个模块,该模块在20x20m单元大小的土壤样本数据上实现autoKrige(自动化库)。一旦克里金完成,我想用场的边界裁剪/掩盖克里金结果。
裁剪/遮蔽的问题在于(由于20x20单元格)字段的边界会产生“步进”效果。我正在寻找的是一个平滑的边界(穿过细胞)。
以下是生成上述两种情况的代码:
library(sp)
library(rgeos)
#create polygon
r1 <- cbind(c(641777, 642290, 642276, 641794), c(7036885, 7036743, 7036154, 7036146))
r2 <- cbind(c(642320, 642478, 642494, 642314), c(7036732, 7036699, 7036296, 7036290))
sr1 <- Polygons(list(Polygon(r1)),"r1")
sr2 <- Polygons(list(Polygon(r2)),"r2")
boundary.sp <- SpatialPolygons(list(sr1,sr2))
boundary.sp@proj4string <- CRS('+proj=utm +zone=35 +south +datum=WGS84 +units=m +no_defs')
#create bounding box grid
bbox <- bbox(boundary.sp)
boundary.grid <- expand.grid(x = seq(from = bbox[1], to = bbox[3], by = 20), y = seq(from = bbox[2], to = bbox[4], by = 20))
coordinates(boundary.grid) <- ~x + y
gridded(boundary.grid) <- TRUE
boundary.grid@proj4string <- boundary.sp@proj4string
#create SpatialPixels grid
boundary.grid.stepped <- boundary.grid[!is.na(over(boundary.grid, boundary.sp)),]
plot(boundary.grid.stepped)
#cut grid with polygon to create SpatialPolygons grid
boundary.poly.grid <- as.SpatialPolygons.GridTopology(getGridTopology(boundary.grid), proj4string = CRS('+proj=utm +zone=35 +south +datum=WGS84 +units=m +no_defs'))
boundary.grid.smooth <- gIntersection(boundary.poly.grid, boundary.sp, byid=TRUE)
plot(boundary.grid.smooth)
当前调用autoKrige时,上面的网格(boundary.grid.stepped)作为'new_data'参数传递。
哪种方法更好,我该如何实施呢?
1)事先准备目标网格并将其用作'new_data'或
2)将克里金法放到边界框网格上,然后切割/裁剪/蒙版?
答案 0 :(得分:0)
我会说直接在目标网格上进行网格化,方法是将其输入new_data
。克里金法结果仅取决于输入数据,所以我怀疑裁剪/计算和计算/裁剪之间几乎没有区别。