R 使用tif提取空间多边形内的值。文件
我正在处理15个空间多边形,希望从tif中提取值。文件(即使用向量)。这是tif。我已经对文件进行了重新分类,以表示坡度数据(每像素) 问题:我已经设法从我的15个多边形中创建了一个“列表”,并检索了与它们的坡度类别相关联的代码,但在整个过程中,我完全无法识别哪个多边形是哪个?有人知道这是为什么吗R 使用tif提取空间多边形内的值。文件,r,R,我正在处理15个空间多边形,希望从tif中提取值。文件(即使用向量)。这是tif。我已经对文件进行了重新分类,以表示坡度数据(每像素) 问题:我已经设法从我的15个多边形中创建了一个“列表”,并检索了与它们的坡度类别相关联的代码,但在整个过程中,我完全无法识别哪个多边形是哪个?有人知道这是为什么吗 #Matrix to categorise my 5 slope categories within each polygon m <- matrix (c(0, 5, 1,
#Matrix to categorise my 5 slope categories within each polygon
m <- matrix (c(0, 5, 1,
5, 10, 2,
10, 15, 3,
15, 20, 4,
20, Inf, 5), ncol=3, byrow=TRUE)
r2 <- reclassify(Slope, m)
r2
plot(r2)
#Loading of polygons (NewHRs02)
All02HRs<-shapefile("L:\\GPSdatabackup\\KERNELS\\NewHRs02")
plot(All02HRs)
All02HRs
#Attempt to extract slope using polygons but i loose recognition of each polygon? THEREFORE WRONG!
Exp02poly <- extract(r2, All02HRs)
summary(Exp02poly)
str(Exp02poly)
class(Exp02poly)
unlist(lapply(Exp02poly, function(x) if (!is.null(x)) freq(x, na.rm=TRUE) else NA ))
##I suspect the final line needs some adjusting but i cannot think what command would be required here.
#矩阵对每个多边形内的5个坡度类别进行分类
I’很抱歉,此文本格式出现问题。谢谢您编辑错误的格式