[R-sig-Geo] Reprojecting a categorical raster using something besides nearest neighbor
Edzer Pebesma
edzer.pebesma at uni-muenster.de
Tue Feb 5 21:52:50 CET 2013
Jonathan, perhaps use
function(x) which.max(table(x))
as the aggregate function?
On 02/05/2013 09:28 PM, Jonathan Greenberg wrote:
> R-sig-geo'ers:
>
> I'm trying to figure out an efficient way to upsample (from higher rez to
> lower rez) a *categorical* raster using a function where the output pixel
> value is the ID of the class that would have had the highest cover within
> the output, given the resampling. This is NOT the same as a nearest
> neighbor function. Right now, the best I can think of is:
> 1) Generate a set of binary masks, one per class, of the input image, where
> for class X, the image X will be 0 if class X is not present, and 1 if it
> is.
> 2) Run aggregate() with a function mean() on these images.
> 3) Pick the max value across the aggregated, lower rez images, which should
> be the class with the highest cover.
>
> Is there any easier way to do this?
>
> --j
>
>
--
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics e.pebesma at wwu.de
More information about the R-sig-Geo
mailing list