loki , , . , angular (/) ()
library(raster)
r <- raster(system.file("external/test.grd", package="raster"))
r <- r / 1000
recalc <- matrix(c(0, 0.05, 0, 0.05, 0.2, 1, 0.2, 0.4, 2, 0.4, 0.6, 3, 0.6, 0.8, 4, 0.8, 2, 5), ncol = 3, byrow = TRUE)
r2 <- reclassify(r, recalc)
1.
f <- freq(r2, useNA='no')
apc <- prod(res(r))
f <- cbind(f, area=f[,2] * apc)
f
2. angular ( )
a <- area(r2)
z <- zonal(a, r2, 'sum')
z
, - :
a <- rasterToPolygons(aggregate(r, 25))
1
ext <- extract(r2, a)
tab <- sapply(ext, function(x) tabulate(x, 5))
tab <- tab * prod(res(r2))
rowSums(tab)
2
x <- rasterize(a, r2)
z <- crosstab(x, r2)
z <- cbind(z, area = z[,3] * prod(res(r2)))
:
aggregate(z[, 'area', drop=F], z[,'Var2', drop=F], sum)
Var2 area
, lon/lat, prod (res (r)), . , , .
. Raster *. :
image(r2)
plot(r2)
spplot(r2)
library(rasterVis);
levelplot(r2)
:
library(ggplot2)
theme_set(theme_bw())
gplot(r2) + geom_tile(aes(fill = value)) +
facet_wrap(~ variable) +
scale_fill_gradient(low = 'white', high = 'blue') +
coord_equal()
library(leaflet)
leaflet() %>% addTiles() %>%
addRasterImage(r2, colors = "Spectral", opacity = 0.8)