get cell number within a distance of one point (raster)

落花浮王杯 提交于 2019-12-07 20:53:51

问题


I need to get the cell numbers within a distance (e.g., 10 km) of one point using R, but I didn't figure out how to handle it for the raster data.

library(raster)
r <- raster(ncols=10, nrows=10)
cellFromXY(r, c(2,2)) # get the cell number of one point

How to get the cell numbers within a distance of one point?


回答1:


Use extract with the buffer option and cellnumbers=TRUE

r <- raster(ncols=100, nrows=100)
  r[]<-runif(ncell(r))

xy <- cbind(-50, seq(-80, 80, by=20))
extract(r, xy[1:3,], buffer=1000000,cellnumbers=TRUE)


来源:https://stackoverflow.com/questions/13996256/get-cell-number-within-a-distance-of-one-point-raster

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!