if (FALSE) {
# Load example data in long format
data(volcano)
volcano3d <- reshape2::melt(volcano)
names(volcano3d) <- c("x", "y", "z")
# Contour plot with default options
contourPlot(volcano3d)
# Import variable CONCAN from inpufile, convert km to m (k = 1000):
data <- importRaster(paste0(dir, inputfile),
k = 1000,
variable = "CONCAN")
# Simple contour plot
contourPlot(data)
# Specifiy (sub)domain to be plotted; background image; legend title and
# pollutant levels.
contourPlot(data,
domain(500000, 510000, 6000000, 6010000, 7, 7),
background = "img/background.png",
legend = "no2 [ug/m3]",
levels = c(10, 20, 30, 40))
# Add underlayer (same for overlayer)
library(ggplot2)
library(maptools)
perimetro <- readShapeLines("path_to/perimetro.shp")
perimetro <- fortify(perimetro)
strada <- readShapeLines("path_to/strada.shp")
strada <- fortify(strada)
myUnderlayer <- vector(mode = "list", length = 2)
myUnderlayer[[1]] <- geom_polygon(data = perimetro,
aes(long, lat, group = group),
colour = "black",
fill = NA,
size = 0.1,
alpha = 0.5)
myUnderlayer[[2]] <- geom_path(data = strada,
aes(long, lat, group = group),
colour = "grey",
size = 0.1,
alpha = 0.5)
contourPlot(data = test,
background = "path_to/basemap.png",
underlayer = myUnderlayer)
# Change default colour palette
contourPlot(data = test,
colors = RColorBrewer::brewer.pal(3, name = "PiYG"))
}
Run the code above in your browser using DataLab