Created
August 27, 2012 10:55
-
-
Save jlehtoma/3487445 to your computer and use it in GitHub Desktop.
Aggreagate with majority
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(raster) | |
# HUOM! Kaikissa hakemistopoluissa pitää Windows-kenoviiva korvata normikenoviivalla | |
# esim. C:\Kansio\tiedosto.txt -> C:/Kansio/tiedosto.txt | |
workspace <- "[KANSIO-JOSSA-LAHTORASTERIT]" | |
# Oletus: rasterit ovat yllä mainitussa kansiossa | |
org.raster.file <- "[ALKUPERAISEN-RASTERIN-NIMI]" | |
agg.raster.file <- "[AGGREGOIDUN-RASTERIN-NIMI]" | |
setwd(workspace) | |
custom.modal <- function(x, ...) { | |
return(modal(x, ties="highest", ...)) | |
} | |
org.raster <- raster(org.raster.file) | |
(aggregate(org.raster, fact=3, fun=custom.modal, | |
filename=agg.raster.file, option=c("COMPRESS=YES"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment