Load the data, tell R -999 means missing values. also
library(terra)
## terra 1.8.54
x = rast('~/Downloads/V6GL02.04.CNNPM25.0p10.GL.201501-201512.nc')
NAflag(x) = -999
plot(x)
again, with a nicer colour scale
setMinMax(x)
pmCol = mapmisc::colourScale(
x, style='equal', transform='log',
dec=-1, breaks=12, col='Spectral',
rev=TRUE)
plot(x, breaks=pmCol$breaks, col=pmCol$col, legend=FALSE)
mapmisc::legendBreaks("left", pmCol)
worldMap = vect(rnaturalearth::ne_countries(type="countries", scale="medium"))
worldMapT = project(worldMap, crs(x))
euro = readRDS("../data/euroSpaceTerra.rds")
euroT = project(euro, crs(x))
mapmisc::map.new(euroT)
plot(x, breaks=pmCol$breaks, col=pmCol$col, add=TRUE, legend=FALSE)
plot(worldMapT, add=TRUE)
mapmisc::legendBreaks("right", pmCol)
pmNuts = extract(x, euroT, fun='mean', na.rm=TRUE)
euro$pm = pmNuts$PM25
euro$sqrtPm = sqrt(euro$pm)
plot(euro$sqrtPm, euro$smr)