Pieter,

I am not sure what what you are trying to do here. Taking the most frequent
(modal) value is something typically done with aggregation, not in
projection. My approach would be to use projectRaster to create a projected
raster with about the same spatial resolution as the original raster, and
then aggregate (the other way around would be faster but probably less
precise). Anyway, if that is what you want to do, I would not mind to add a
'fun' argument to projectRaster that would allow you to do what you want. It
would make more sense if you project to a raster with a much larger
resolution.

By the way, there is a modal function in raster. so Jacob's suggestion is
equivalent to

aggregate(x, fun=modal)

Robert


On Fri, Sep 16, 2011 at 1:32 PM, Jacob van Etten <jacobvanetten@yahoo.com>wrote:

> What about this?
>
>
> library(prettyR)
>
> aggregate(x, fun=Mode)
>
> Jacob
>
>
>
> ________________________________
> From: Pieter Beck <pbeck@whrc.org>
> To: r-sig-geo@r-project.org
> Sent: Friday, 16 September 2011, 19:01
> Subject: [R-sig-Geo] projectRaster, MAJORITY method, rather than ngb?
>
> Dear all,
>
> I am using raster's projectRaster to project a raster of a categorical
> variable to a grid of coarser resolution (which I specify using another
> raster object as the 'to' parameter). Rather than assigning the new cells
> the value originally found closest to their centers (i.e. the 'ngb'
> method),
> I'd like to assign the new cells the value originally found most commonly
> within them.
>
> I understand that such a 'majority' method is currently not part of the
> projectRaster command, but would welcome suggestions for an elegant
> work-around or modification to the projectRaster code.
>
> thanks,
>
> Pieter
>
>
>     [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>         [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>

	[[alternative HTML version deleted]]

