[R-sig-Geo] focalFilter function in raster
Robert Hijmans
r.hijmans at gmail.com
Tue Apr 12 05:19:13 CEST 2011
Dear Andy,
Not your mistake, but mine. Like in Nick's case a few days ago, this reveals
a serious error in focalFilter. Results with that function in raster
versions lower than 1.8-12 (I said 1.8-11 in a previous message) are wrong
in the first rows (half the number of rows of the filter), when using a
filter larger than 3x3. Version 1.8-12 is on its way to CRAN.
Robert
> Hi all,
> I'm using the focalFilter function in the raster package to
> process a raster DEM. I've cropped the data back to a tiny area to make
> it easier to see. I am expecting focalFilter to apply a matrix of
> weights (in this case 1s in a 5x5 grid) to the cells surrounding each
> cell, and then evaluate the supplied function for the result i.e in the
> first case below simply the max value of all the cells in a 5x5 grid
> centred on each cell in turn. This works as expected.
>
> However the "min" function doesnt - the value 63.4079 is in the extreme
> top-right corner of the raster, so only falls within the 5x5 grid around
> the 16th cell (top-right of the 4 evaluated) yet this value is also
> evaluated as the result for the other 3 cells as well, despite not
> falling within the 5x5 matrix around these cells. Min works with 3x3 but
> not 5x5 and larger. This is only for illustration not something I'm
> actually want to do - I want to apply "median" with a 27x27 grid, and I
> also get the same problem here but the data for that's not so obvious ;-)
>
> Can someone please point out my obvious mistake?
> Cheers
> Andy
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/focalFilter-function-in-raster-tp6262205p6263710.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
More information about the R-sig-Geo
mailing list