问题
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