[RS-ecology] Moving Window
Ruben Remelgado
ruben.remelgado at uni-wuerzburg.de
Tue Jul 25 18:34:44 CEST 2017
Hi Leila,
Here is a workaround. You can aggregate your raster first
/or <- raster('file') /# original
/ar <- aggregate(or, fact=2, fun='your function')/ # aggregated raster
And then use the extract function. xyFromCell() gives you the
coordinates for each pixel in your original raster and you can use them
to query your aggregated raster. Then you just build a new raster using
the original one as a reference.
/nr <- setValues(or, extract(ar, xyFromCell(or)))/ # new raster
On 21-07-2017 11:55, Leila Schuh wrote:
> Dear all,
>
> I am trying to run analyses on raster data and am stuck with a
> specific problem.
>
> I would like to create a moving window, which doesn’t assign
> individual values to all pixels included in the window, but one value
> for all pixels (within the window). Consequently, I would like to
> “paste the windows next to each other” rather than running
> calculations for every individual pixel.
>
> I haven’t figured out how to do this with focal or focalWeight. (I
> also tried to use aggregate instead of a moving window, but it doesn't
> allow me to use self-defined functions.)
>
> If anyone could help me out with this, that would awesome!
>
> I'll send a tiny bit of code and the raster file I'm working with.
>
> Thank you and best wishes,
> Leila
>
>
>
> _______________________________________________
> RS-ecology mailing list
> RS-ecology at lists.uni-wuerzburg.de
> https://lists.uni-wuerzburg.de/mailman/listinfo/rs-ecology
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.uni-wuerzburg.de/pipermail/rs-ecology/attachments/20170725/6eba512a/attachment.html>
More information about the RS-ecology
mailing list