简体   繁体   English

从 R 中的马赛克 (ArcGIS) 中提取波段值到点

[英]Extract band values to points from mosaic (ArcGIS) in R

I am classifying satellite images in ArcGIS.我在 ArcGIS 中对卫星图像进行分类。 I would like to partially evaluate my results in R, eg through Crossvalidation.我想部分评估我在 R 中的结果,例如通过交叉验证。 I want with mosaic (raster with 6 bands) extract band values to points but from my raster it only gets values from 1 band.我想用马赛克(6 个波段的栅格)将波段值提取到点,但从我的栅格中它只能从 1 个波段获取值。 How to get values from each bands?如何从每个波段获取值?

Below is the code I used:下面是我使用的代码:

df <- mosaic %>% 
extract(y = points) %>%  
as.data.frame %>% 
mutate(id_cls = points@data$id_cls) %>% 
left_join(y = unique(poly@data), by = c("id_cls" = "id")) %>% 
mutate(id_cls = NULL) 

I would like to receive data.frame with the values of all bands at selected points.我想接收 data.frame 与选定点的所有波段的值。

When asking a R question you should provide a minimal, self-contained, reproducible example.在询问 R 问题时,您应该提供一个最小的、独立的、可重现的示例。 For example, like this, with a minor modification from ?extract例如,像这样,从?extract

r <- raster(ncol=36, nrow=18, vals=1:(18*36))
s <- stack(r,r,r)  # similar to your mosaic 
# from what I see you are using polygons to extract?
cds1 <- rbind(c(-180,-20), c(-160,5), c(-60, 0), c(-160,-60), c(-180,-20))
cds2 <- rbind(c(80,0), c(100,60), c(120,0), c(120,-55), c(80,0))
polys <- spPolygons(cds1, cds2)

v <- extract(r, polys)
str(v)
#List of 2
# $ : num [1:38] 326 327 328 329 330 331 332 333 334 335 ...
# $ : num [1:23] 173 208 209 244 245 280 281 282 315 316 ...
 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM