使用tif在空间多边形内提取值。文件

时间:2014-11-05 10:29:36

标签: r

我正在处理15个空间多边形,并希望从tif中提取值。文件(即使用向量)。这个tif。文件已经被我重新分类以表示斜率数据(每个像素)。

问题:我已经设法从我的15个多边形中创建了一个“列表”,并且还检索了与斜坡倾斜类别相关联的代码,但在整个过程中,我已经失去了对哪个多边形的识别?有谁知道这是为什么?

#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.

希望有人可以提供帮助

0 个答案:

没有答案
相关问题