Changes between Version 11 and Version 12 of udg/ecoms/RPackage/examples


Ignore:
Timestamp:
Apr 19, 2013 10:39:09 AM (9 years ago)
Author:
juaco
Comment:

--

Legend:

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

    v11 v12  
    3030}}}
    3131
    32 A common task consists of the representation of data, e.g. by mapping the spatial mean for the period considered:
     32A common task consists of the representation of data, e.g. by mapping the spatial mean for the period considered. Another common task is the representation of time series for selected point locations/grid cells. As an example, we will display time series of the requested dataset at four grid points coincident with the locations of four Spanish cities:
    3333
    3434{{{
     35> city.names <- c("Sevilla", "Madrid", "Santander", "Zaragoza")
     36> locations <- matrix(c(-5.9, 37.4167, -3.68, 40.4, -3.817, 43.43, -0.8167, 41.667), ncol=2, byrow = TRUE)
     37> dimnames(locations) <- list(city.names, c("lon","lat"))
     38> print(locations)
     39             lon     lat
     40Sevilla   -5.9000 37.4167
     41Madrid    -3.6800 40.4000
     42Santander -3.8170 43.4300
     43Zaragoza  -0.8167 41.6670
     44}}}
     45
     46In the following lines of code we calculate the mean temperature field and plot it, In addition, we also add to the map the point locations of the selected cities for which the time series will be represented:
     47
     48{{{
     49> # Representation of the mean temperature of the period
    3550> mean.field <- colMeans(openDAP.query$MemberData[[1]])
    3651> lat <- openDAP.query$LatLonCoords[ ,1]
    3752> lon <- openDAP.query$LatLonCoords[ ,2]
    38 > # Requires package "akima"
     53> # Requires "akima::interp" for regular grid interpolation
    3954> library(akima)
    4055> filled.contour(interp(lon, lat, mean.field), asp=1,
     
    4257+               key.title = title(main = "degC"),
    4358+               key.axes = axis(4, seq(-1,16,1)),
     59+               plot.axes = {points(locations, pch=15); axis(1); axis(2); text(locations, cex=.8, pos=3, city.names)},
    4460+               color.palette = topo.colors)
    4561}}}
    46 
    47 [[Image(tracFig.png)]]