【发布时间】:2016-06-03 13:40:16
【问题描述】:
我在R 中使用raster 包并在shapefile 包含多个polygons (200) 的光栅上执行extract。每个多边形都有一个列,其中指定了多边形的class。
当我执行extract 时,我得到一个dataframe,其中栅格的每个值都“分配”给一个多边形:哪个多边形位于哪个像素中。但是,我的多边形包含的信息(即它们是什么类)已经消失了。 extract 之后的我的数据框看起来像:
test <- extract(myRaster, myTrainingPolygon, df = TRUE)
ID band1 band2 band3
1 0.101 0.827 ...
... ... ... ...
200 0.876 0.821 ...
我需要的是类似的东西
ID band1 band2 band3 class
1 0.101 0.827 ... class1
... ... ... ... ...
200 0.876 ... ... class3
我如何在其中获取信息 - 或者首先 - 在执行提取时不要丢失它们?!
【问题讨论】:
-
你能提供一个你的 shapefile 的例子吗?
标签: r polygon raster geography r-raster