Changes between Version 45 and Version 46 of udg/ecoms/RPackage/examples


Ignore:
Timestamp:
Feb 17, 2014 2:55:38 PM (8 years ago)
Author:
juaco
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • udg/ecoms/RPackage/examples

    v45 v46  
    66
    77{{{
    8 > gg.pr <- loadSeasonalForecast("System4_seasonal_15", var="tp", lonLim=c(-30,20),
    9 + latLim=c(-12,15), season=1, years=2010, leadMonth=3)
    10 
     8gg.pr <- loadSeasonalForecast("System4_seasonal_15", var="tp", lonLim=c(-30,20), latLim=c(-12,15), season=1, years=2010, leadMonth=3)
    119}}}
    1210
    13 {{{
    14 names(gg.pr)
    15 str(gg.pr$MemberData)
    16 }}}
    17 
     11Next, total accumulated precipitation is computed for each grid point, and a `SpatialGridDataFrame` is created:
    1812
    1913{{{
    20 pr.list <- lapply(1:length(gg.pr$MemberData), function(x) colSums(gg.pr$MemberData[[x]]))
    21 df <- do.call("data.frame", pr.list)
    22 names(df) <- names(gg.pr$MemberData)
    23 }}}
    24 
    25 {{{
    26 class(gg.pr$LonLatCoords)
    27 sgdf <- SpatialGridDataFrame(gg.pr$LonLatCoords, df)
    28 }}}
    29 
    30 {{{
    31 spplot(sgdf, scales=list(draw = TRUE), col.regions = rev(terrain.colors(50)), at = seq(0, ceiling(max(sgdf@data)),10))
     14df <- sapply(gg.pr$MemberData, colSums)
     15sgdf <- SpatialGridDataFrame(gg.pr$LonLatCoords, as.data.frame(df))
     16spplot(sgdf, scales=list(draw=TRUE), col.regions=rev(terrain.colors(50)), at=seq(0,ceiling(max(sgdf@data)),10))
    3217}}}
    3318
    3419[[Image(GulfOfGuinea15members.png)]]
    3520
    36 It is often useful to have a world map underneath as a visual reference
     21It 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:
    3722
    3823{{{
    39 > data(world_map)
    40 > wl <- as(world_map, "SpatialLines")
    41 > l1 <- list("sp.lines", wl)
     24data(world_map)
     25wl <- as(world_map, "SpatialLines")
     26l1 <- list("sp.lines", wl)
    4227}}}
    4328
    44 Suppose we are interested in the visualization of four particular members, forecasting a particularly high precipitation over the southern region. We can choose which ones to display using the `zcol` argument:
     29For 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:
    4530
    4631{{{
    47 > spplot(sgdf, zcol = c(4,9,13,14), scales=list(draw = TRUE), col.regions = rev(terrain.colors(50)),
    48 + at = seq(0, ceiling(max(sgdf@data)),10), sp.layout = list(l1))
     32spplot(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))
     33}}}
    4934
    50 }}}
    5135[[Image(GulfOfGuineaSubsetMember.png)]]