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.pebe...@wwu.de _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo