Aggregate the values in a raster that lie within a given distance from a given point (i.e. a circle)

独自空忆成欢 提交于 2019-12-12 00:34:49

问题


I have a raster file nightlights that maps nighttime luminosity from satellite imagery (300MB compressed data available here). It takes longitude-latitude inputs for extraction, e.g. extract(nightlights, data.frame(long, lat) for long-lat inputs.

Given point <- (long, lat), I want to be able to aggregate all values that lie within, say, 5 miles of point and calculate an average luminosity, ignoring NAs.

The raster package comes with an aggregate method that performs this function, but only for rectangles rather than spherical circles.


回答1:


I think you can use the buffer argument for that:

e <- extract(nightlights, cbind(long, lat), buffer=10)


来源:https://stackoverflow.com/questions/32830821/aggregate-the-values-in-a-raster-that-lie-within-a-given-distance-from-a-given-p

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