# NOT RUN {
## The examples below will only be run if sufficient time is allowed
## You can change that by typing e.g. IsoriX.options(example_maxtime = XX)
## if you want to allow for examples taking up to ca. XX seconds to run
## (so don't write XX but put a number instead!)
if(IsoriX.getOption("example_maxtime") > 30) {
## We fit the models for Germany
GNIPDataDEagg <- prepdata(data = GNIPDataDE)
GermanFit <- isofit(iso.data = GNIPDataDEagg,
mean.model.fix = list(elev = TRUE, lat.abs = TRUE))
### Let's explore the difference between aggregation schemes
## We aggregate and crop using different settings
elevation.raster1 <- relevate(
elevation.raster = ElevRasterDE,
isofit = GermanFit,
margin_pct = 0,
aggregation.factor = 0)
elevation.raster2 <- relevate(
elevation.raster = ElevRasterDE,
isofit = GermanFit,
margin_pct = 5,
aggregation.factor = 5)
elevation.raster3 <- relevate(
elevation.raster = ElevRasterDE,
isofit = GermanFit,
margin_pct = 10,
aggregation.factor = 5, aggregation.fun = max)
## We build the plots of the outcome of the 3 different aggregation schemes
if(require(rasterVis)) {
plot.aggregation1 <- levelplot(elevation.raster1,
margin = FALSE, main = "Original small raster") +
layer(sp.polygons(CountryBorders)) +
layer(sp.polygons(OceanMask, fill = "blue"))
plot.aggregation2 <- levelplot(elevation.raster2,
margin = FALSE, main = "Small raster aggregated (by mean)") +
layer(sp.polygons(CountryBorders)) +
layer(sp.polygons(OceanMask, fill = "blue"))
plot.aggregation3 <- levelplot(elevation.raster3,
margin = FALSE, main = "Small raster aggregated (by max)") +
layer(sp.polygons(CountryBorders)) +
layer(sp.polygons(OceanMask, fill = "blue"))
## We plot as a panel using lattice syntax:
print(plot.aggregation1, split = c(1, 1, 1, 3), more = TRUE)
print(plot.aggregation2, split = c(1, 2, 1, 3), more = TRUE)
print(plot.aggregation3, split = c(1, 3, 1, 3))
}
}
#' ## The examples below will only be run if sufficient time is allowed
## You can change that by typing e.g. IsoriX.options(example_maxtime = XX)
## if you want to allow for examples taking up to ca. XX seconds to run
## (so don't write XX but put a number instead!)
if(IsoriX.getOption("example_maxtime") > 10) {
### Let's create a raster centered around the pacific
## We first create an empty raster
empty.raster <- raster(matrix(0, ncol = 360, nrow = 180))
extent(empty.raster) <- c(-180, 180, -90, 90)
projection(empty.raster) <- CRS("+proj=longlat +datum=WGS84")
## We crop it around the pacific
pacificA <- relevate(empty.raster, manual.crop = c(110, -70, -90, 90))
extent(pacificA) # note that the extent has changed!
## We plot (note the use of the function shift()!)
if(require(rasterVis)) {
levelplot(pacificA, margin = FALSE, colorkey = FALSE, col = "blue")+
layer(sp.polygons(CountryBorders, fill = "black"))+
layer(sp.polygons(shift(CountryBorders, x = 360), fill = "black"))
}
}
# }
Run the code above in your browser using DataLab