Version 2 (modified by juaco, 8 years ago) (diff)

--

The spplot methods of package sp allow the visualization of maps for different spatial classes using trellis (lattice) plots. In this example, total precipitation at the Gulf of Guinea for January 2010 forecasted in October 2009 (lead month 3) by the System4 model (seasonal range, 15 members) is represented for each member, using the spplot method for the SpatialGridDataFrame class:

Data are loaded by introducing the required values for dataset, spatio-temporal window and lead month definition. Note that the argument members is omitted, which means that by default all available members (15 in this case, will be returned).

gg.pr <- loadSeasonalForecast("System4_seasonal_15", var="tp", lonLim=c(-30,20), latLim=c(-12,15), season=1, years=2010, leadMonth=3)


Next, total accumulated precipitation is computed for each grid point, and a SpatialGridDataFrame is created:

df <- sapply(gg.pr$MemberData, colSums) sgdf <- SpatialGridDataFrame(gg.pr$LonLatCoords, as.data.frame(df))
spplot(sgdf, scales=list(draw=TRUE), col.regions=rev(terrain.colors(50)), at=seq(0,ceiling(max(sgdf@data)),10))


It is often useful to have a world map as a backdrop for visual reference. The dataset world_map is built-in in the ecomsUDG.Raccess package:

data(world_map)
wl <- as(world_map, "SpatialLines")
l1 <- list("sp.lines", wl)


For the visualization of a subset of members we use the zcol argument. For instance, members 4, 9, 13 and 14 yield a high precipitation forecast in the southern region:

spplot(sgdf, zcol=c(4,9,13,14), scales=list(draw=TRUE), col.regions=rev(terrain.colors(50)), at=seq(0, ceiling(max(sgdf@data)),10), sp.layout=list(l1))