michael greenacremichael greenacre universitat pompeu ...michael/visualdata/visualization3.pdf · 4...
TRANSCRIPT
Master of Data Science, Barcelona GSE, 2nd term 2016, ,
Vizualizing spatial data
Michael GreenacreMichael GreenacreUniversitat Pompeu Fabra
BarcelonaBarcelonawww.econ.upf.edu/~michael www.globalsong.net
www.multivariatestatistics.org
Course email: [email protected] website: www.econ.upf.edu/~michael/visualdata
Spatial datacoordinatevalues (1d, ( ,2d or 3d)
variables
• sometimes (but rarely) samples are taken on a regular grid; for somefunctions data will have to be interpolated to a regular grid
• region of interest could be non-geographic, e.g. in an experiment or in a local area
• when data associated with a map, we often talk of geospatial data p, g p
• geospatial intelligence (GEOINT) is concerned with earth imagery, often fromsatellites of human (often military) activity exploitation climatesatellites, of human (often military) activity, exploitation, climate, …
• spatial data often accessed, manipulated, analysed through geographicinformation systems (GIS)information systems (GIS)
Vector vs. raster
discrete objects continuous fieldsje.g. road, river, letters e.g., elevation, temperature,
photographsrepresented with represented withrepresented withvector data, e.g.points, lines, polygons [metafiles
represented withraster (pixel) data, e.g. points, shaded
l [bipolygons [metafiles, PostScript, PDF…]
polygons [bitmap, JPG, PNG…]
can be rescaled without become blurry whencan be rescaled withoutloss of precision
become blurry whenenlarged
R
d l ti l ti
R package sp R package raster
good resolution poor resolutionpoor colour good colour
p g p p g
See CRAN Task Views “Analysis of Spatial Data” http://CRAN.R-project.org/view=Spatial
R package sp
SpatialPointsDataFrameSpatialLinesDataFrameSpatialLinesDataFrame
SpatialPointsSpatialGridLine / Lines / SpatialLinesPolygon / Polygons / SpatialPolygons
[ selects rows & columns in data frame[[ selects a column from a data frame[[ <- assigns or replaces values to a column in a data frame[[ < assigns or replaces values to a column in a data frame
coordinates(object) <- value sets coordinates to create spatial databbox returns matrix with bounding boxbbox returns matrix with bounding boxproj4string(object) <- value sets projection attributes on spatial
classes*T f t f di t f t ( i d l)spTransform transforms coordinate reference system (requires rgdal)
spplot plots attributes combined with spatial data (points, lines, grids, polygons)
*Overview of Coordinate Reference Systems in R, on course websitePROJ.4 is a library, accessible from R for transforming cartographic projections
Until a projection is defined, the co-ordinates are just numbers; they are not related to the Earth’s surface. This can be useful for“spatial”analysis of non-Earth objects, e.g. an image from a microscope. For true geographic analysis, the object must be related to the Earth’s shape. Then true distances and azimuths can be computed.
Spatial object# fish is data frame of abundance data of 30 fish, 89 stations
# fish.lldt is data frame of latitude, longitude, depth and temperature
> fi h < S ti lP i t D t F (d t fi h d fi h lldt[ (2 1)])
good practice toput longitude first, then latitude
> fish.sp <- SpatialPointsDataFrame(data=fish, coords=fish.lldt[,c(2,1)])
> fish.spoordinates Re_hi An_de An_mi Hi_pl An_lu Me_ae Ra_ra Mi_po Ar_at No_rk Lu_la Ma_vi Bo_sa Cy_lu ...
356 (22.43, 71.1) 0 0 0 31 0 108 0 325 0 0 0 2 0 1 ...
357 (23.68, 71.32) 0 0 0 4 0 110 0 349 0 1 0 0 0 0 ...
358 (24.9, 71.6) 0 0 0 27 0 788 0 6 0 0 0 0 0 0 ...
359 (25.88, 71.27) 0 0 1 13 0 295 0 2 0 0 0 3 0 0 ...
363 (28.12, 71.52) 0 0 0 23 0 13 2 240 0 0 0 16 0 1 ...
364 (29 1 71 48) 1 0 0 20 0 97 0 0 0 0 0 0 0 0364 (29.1, 71.48) 1 0 0 20 0 97 0 0 0 0 0 0 0 0 ...
: : : : : : : : : : : : : : : : : ...
> library(mapproj) coordinates projectiony( pp j)
> fish.coords <- mapproject(fish.lldt[,2], fish.lldt[,1],
projection='orthographic')
> fish.sp <- SpatialPointsDataFrame(data=fish, plot w/o projection plot w projection
coordinates projection
p p ( ,
coords=cbind(fish.coords$x, fish.coords$y))
> fish.col <- rev(brewer.pal(5,"RdYlBu"))
> fish.col[3] <- "#EEDDEE"> fish.col[3] < #EEDDEE
> spplot(fish.sp["Ma_vi"], key.space="right",
cuts=quantile(fish[,"Ma_vi"],
probs=c(0 0 135 0 4 0 6 0 9 1))probs=c(0,0.135,0.4,0.6,0.9,1)),
col.regions=fish.col)
Plotting station network with colour coding of variable# making 3D plot of station locations and coding temperatures in 5 classes
require(RColorBrewer)
di l b ll(6) checking ColorBrewer palettesdisplay.brewer.all(6)
temp.class <- cut(fish.lldt[,4], 5)
temp.col <- brewer.pal(6, "GnBu")[seq(6,2,-1)]
checking ColorBrewer palettes
choose 6 colours but drop firstone which is very light
open3d()
plot3d(fish.coords$x, fish.coords$y, -fish.lldt[,3], type="n", xlab="x", ylab="y", zlab="depth")
points3d(fish coords$x fish coords$y -fish lldt[ 3]points3d(fish.coords$x, fish.coords$y, -fish.lldt[,3], col=temp.col[as.numeric(temp.class)], size=10)
Map projectionsPlanar/azimuthal projections
Azimuthal projections with different perspectives
from earth centre from pole to pole from infinity
See “Understanding map projections” on course webpage
Azimuthal maps
Focus: Bear Island (Bjornøya) Focus: Barcelona( j y )
http://ns6t.net/azimuth/azimuth.html
R package raster
Formats supported: GeoTIFF, ESRI, ENVI and ERDAS… (e.g., GeoTIFF is a public domain metadata standard which allows georeferencing information to be embedded within a TIFF file. The potential additional information includes map projection, coordinate systems, ellipsoids, and everything else necessary to establish the exact spatial reference for the file.ESRI (Environmental Systems Research Institute)ESRI (Environmental Systems Research Institute)
www.esri.com: markets ArcGIS software [see next slide for example]see http://www.esri.com/software/arcgis
ENVI (Environment for Visualizing Images) www.exelisvis.com/ProductsServices/ENVIProducts.aspx
ERDAS (Earth Resources Data Analysis System)www.hexagongeospatial.com/products/remote-sensing/erdas-imagine/overview
raster can work with large datasets stored on disk, since itprocesses data in chunks
RasterLayer single-layer (variable) raster data, created with functionraster which can also create a RasterLayer fromraster, which can also create a RasterLayer fromvector objects (e.g. SpatialGrid).
RasterBrick and RasterStack for multi-layer data (i.e. multivariate) with same spatial extent and resolution
R package rasterVIS
Complements t package defining is ali ation methods (e gComplements raster package, defining visualization methods (e.g., levelplot) for quantitative and categorical data, both for uni- and mutivariate rasters.Also includes basic plot functions such as xyplot, histogram, densityplot, bwplot, splom in spatial context.Al di l t d t i t l t t l tAlso displays vector data using arrows, vectorplot, streamplot
R package maptools
Tools for manip lating and reading geographic data e g pro idesTools for manipulating and reading geographic data, e.g. providesinterface for exchanging spatial objects with other packages.
R package rgdalR package rgdal
Provides bindings to the Geospatial Data Abstraction Library (GDAL)http://www.gdal.org
(translator library for raster and vector geospatial data formats – and thereare a lot of them!)Provides access to projection and transformation operations from theProvides access to projection and transformation operations from thePROJ.4 cartographic projections library
https://trac.osgeo.org/projp g g p j
R package gstat
Geostatistical modelling, prediction and simulation, including methodsof kriging: functions variogram and krigeof kriging: functions variogram and krige.
R packages d t jR packages maps, mapdata, mapproj
For drawing geographical maps. maps: draws mapsmapdata: high resolution databasesmapproj: converts latitude/longitude into projected coordinates
Open-source literature and software
website by Tomislav Hengl: http://spatial-analyst.netcreate maps for web using Kartograph at http://kartograph.org : p g g p p g p g
see beautiful maps at: http://spatialanalysis.co.uk/map-gallery
Data set “NO2sp”Data from grid of sensors in Integrated Air Quality System of
Madrid. 24 stations analysing several gases and particles. Weuse only the NO data series which has already been converteduse only the NO2 data series, which has already been converted
to a SpatialPointsDataFramecoordinates Nombre alt codEst mean median sd
1 (-3.703172, 40.41921) Pza. del Carmen 657 28079035 51.0 46 18.62 (-3.712333, 40.42399) Pza. de España 637 28079004 50.6 49 18.33 (-3.711542, 40.47823) Barrio del Pilar 673 28079039 49.3 43 24.24 (-3.682319, 40.42156) Escuelas Aguirre 672 28079008 59.6 58 17.75 ( 3 707128 40 43333) C t C i 699 28079038 54 6 51 22 75 (-3.707128, 40.43333) Cuatro Caminos 699 28079038 54.6 51 22.76 (-3.677353, 40.45147) Av. Ramón y Cajal 708 28079011 53.6 51 21.87 (-3.651522, 40.38815) Vallecas 677 28079040 44.2 41 20.0: : : : : : : :
N.B. coordinatesexpressed as
decimal longitudeNotice that coordinates are treated as a single variable: this distinguishes a spatial data framef
Madrid west of Greenwich??
gand latitude from a regular one in R
load("data/NO2sp.Rdata")dim(NO2sp)[1] 24 6
NO2 levels in Madrid2
Using spplot
C l d i40.5N
Colour and sizeare used to depictthe same thing,
40 45N
the level of NO2categorized into5 levels.
40.45N
[22.5,30.48](30.48,38.46](38.46,46.44]
5 levels.
40.4N
(46.44,54.42](54.42,62.4]
Using bubblesizes cex=1 to 5, the categories are
40.35N
the categories are not easy todiscriminate
3.75W 3.7W 3.65W 3.6W
colourRampPalette, intervals & circle sizeairPal <- colorRampPalette(c("springgreen1", "sienna3", "gray5"))(5)
define interpolationsspplot(NO2sp["mean"], col.regions=airPal, cex=sqrt(1:5),
edge.col="black", scales=list(draw=TRUE),
key space="right")
between selectedcolours (choices of interpolation)
key.space= right )
# improvements
circle sizes from 1 to 5many options for
defining intervals: library(classInt)
nClasses <- 5
intervals <- classIntervals(NO2sp$mean, n=nClasses, style="fisher")
Fisher(-Jenks) optimizeshomogeneity
nClasses <- length(intervals$brks)-1
# complete set of circle radii (mm)
set of 10 radiifound byexperimentationt b ll# p ( )
dent <- c(0.64, 1.14, 1.65, 2.79, 4.32, 6.22, 9.65, 12.95, 15.11)
# subset for us
dentAQ < dent[seq len(nClasses)]
to be well-discriminated forincreasing levels
dentAQ <- dent[seq_len(nClasses)]
# link size and class
# findCols returns class number of each point (which interval they fall in)
idx <- findCols(intervals)
cexNO2 <- dentAQ[idx]
NO2 levels in Madrid: improved classes2
Classes determined from theFisher-Jenks optimalclassification algorithm.Sequence of 10 radii derived
40.5N
Sequence of 10 radii derivedfrom an experiment ondistinguishing circle sizes:
40 45Ndent <- c(0.64, 1.14, 1.65, 2.79, 4.32, 6.22, 9.65, 12.95, 15.11)
40.45N
, , )
We take first five of above.40.4N
Also, we bring the key insideand show how to title it withsubscripts and Greek letters:subscripts and Greek letters:title=expression(NO[2]~~(paste(mu, plain(g))/m^3))
40.35NNO2g m3
[22.5,33)[33,42.05)[42.05,48.95)[48.95,57.1)[57 1 62 4]
3.75W 3.7W 3.65W 3.6W
[57.1,62.4]
NO2 levels in Madrid: shown on map2
kUses packageOpenStreetMap
NO2 levels in Madrid: shown on map2
kUses packageggmap
NO2 levels in Madrid: spatial interpolation2
Uses package gstatand function krigegto interpolate
Problem here is thatbecause is israsterized we cannotadd otherinformation.Y dd M d idYou can add Madrid streets as well using(vectorized) shapefiles-- but this is quite a bit more work!. For Madrid these filesFor Madrid these files of streets can beobtained fromhtt // d idhttp://www.madrid.org/nomescalles
Using external data viewersGeoJSON, rendered on GitHub
GeoJSON is a geospatial-enhanced versionenhanced versionof JSON (Java Script ObjectNotation) open file format forencodingencodinggeographicalfeatures plus some nonspatialattributes; uses “human readable”human-readable text
https://github.com/oscarperpinan/spacetime-vis/blob/master/data/NO2.geojson
Example of file generated from package rgdallibrary(rgdal)writeOGR(NO2sp, "NO2.geojson", "NO2sp", driver="GeoJSON")
"type": "FeatureCollection","crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "id": 1, "properties": { "Nombre": "Pza. del Carmen", "alt": 657, "codEst": 28079035.000000, "mean": 51.000000, "median": 46.000000, "sd": 18.600000, "classNO2": "[48.95,57.1)" }, "geometry": { "type": "Point", "coordinates": [ -3.70317222222222, 40.419208333333302 ] } },
{ "type": "Feature" "id": 2 "properties": { "Nombre": "Pza de España" "alt": 637 "codEst": 28079004 000000{ "type": "Feature", "id": 2, "properties": { "Nombre": "Pza. de España", "alt": 637, "codEst": 28079004.000000, "mean": 50.600000, "median": 49.000000, "sd": 18.300000, "classNO2": "[48.95,57.1)" }, "geometry": { "type": "Point", "coordinates": [ -3.71233333333333, 40.423991666666701 ] } },
{ "type": "Feature", "id": 3, "properties": { "Nombre": "Barrio del Pilar", "alt": 673, "codEst": 28079039 000000 "mean": 49 300000 "median": 43 000000 "sd": 24 200000 "classNO2": "[48 95 57 1)" }28079039.000000, "mean": 49.300000, "median": 43.000000, "sd": 24.200000, "classNO2": "[48.95,57.1)" }, "geometry": { "type": "Point", "coordinates": [ -3.71154166666667, 40.478227777777803 ] } },:::{ "type": "Feature" "id": 22 "properties": { "Nombre": "El Pardo" "alt": 616 "codEst": 28079058 000000{ "type": "Feature", "id": 22, "properties": { "Nombre": "El Pardo", "alt": 616, "codEst": 28079058.000000, "mean": 22.500000, "median": 20.000000, "sd": 12.400000, "classNO2": "[22.5,33)" }, "geometry": { "type": "Point", "coordinates": [ -3.76666666666667, 40.516666666666701 ] } },
{ "type": "Feature", "id": 23, "properties": { "Nombre": "Parque Juan Carlos I", "alt": 669, "codEst": 28079059 000000 "mean": 28 000000 "median": 27 000000 "sd": 13 800000 "classNO2": "[22 5 33)" } "geometry":28079059.000000, "mean": 28.000000, "median": 27.000000, "sd": 13.800000, "classNO2": "[22.5,33)" }, "geometry": { "type": "Point", "coordinates": [ -3.60888888888889, 40.465 ] } },
{ "type": "Feature", "id": 24, "properties": { "Nombre": "Tres Olivos", "alt": 715, "codEst": 28079060.000000, "mean": 38.800000, "median": 35.000000, "sd": 20.000000, "classNO2": "[33,42.05)" }, "geometry": { "type": "Point" "coordinates": [ 3 68333333333333 40 5005555555556 ] } }"Point", "coordinates": [ -3.68333333333333, 40.5005555555556 ] } }]}
Keyhole Markup Language (KML)International standard file format to display geographic data withininternet based 2 d and 3 d earth browsers e g :internet-based 2-d and 3-d earth browsers, e.g.:
Google earth https://www.google.com/earth/ or Marble https://marble.kde.org/
rgdal can write KML files, butid i l i fplotKML provides simpler interface
lib ( l tKML)library(plotKML)plotKML(NO2sp["mean"], points_names=NO2sp$codEst)
Open resultant file in Google earth
It is possible to add information or hyperlinks to the circles in an SVGIt is possible to add information or hyperlinks to the circles in an SVG graphic such as a photograph, data, location name… using gridSVGpackage. These appear as small windows, called “tooltips” whenmouse hovers over the circle The following demonstrates hyperlinks:mouse hovers over the circle. The following demonstrates hyperlinks:Open airMadrid.html in browser and click on a circle.
Chloropleth mapsShades a region of a map uniformly according to measurementof a variable in that region.gWe use the results of the 2011 Spanish general elections, a data set called ‘votes2011.csv’.
winning party votes %
PROVMUN whichMax Max pcMax1 04001 PSOE 516 44.986922 04002 PP 550 47.169813 04003 PP 6763 38.950644 04004 PSOE 310 49.050635 04005 PP 346 52.986226 04006 PSOE 2785 35.903067 04007 PSOE 369 46.12500
8084 rows
8 04008 PP 359 65.750929 04009 PSOE 43 26.7080710 04010 PSOE 300 48.70130: : : : :
Getting municipal boundaries & plotting shaded map& plotting shaded map
Go to Instituto Nacional de Estadistica (INE) at www.ine.esTh P d t d i D l d th PC iThen -> Products and services -> Download the PC-axis programThen download 74mb RAR file, and unrar the file
Read polygons for municipalities and provinces:Read polygons for municipalities and provinces:espMap <- readShapePoly(fn="esp_muni_0109")provinces <- readShapePoly(fn="spain_provinces_ag_2")# ( )# dissolve repeated polygons (requires package rgeos)espPols <- unionSpatialPolygons(espMap, espMap$PROVMUN)
Matching polygons and data using ID slot: Canarias?Matching polygons and data using ID slot:IDs <- sapply(espPols@polygons, function(x)x@ID)idx <- match(IDs, votes2011$PROVMUN)
Add data values to SpatialPolygons object:dat2add <- votes2011[idx, ]
(d t2 dd) IDrow.names(dat2add) <- IDsespMapVotes <- SpatialPolygonsDataFrame(espPols, dat2add)
Plot map:pqualPal <- rainbow_hcl(nClasses, start=30, end=300)spplot(espMapVotes["whichMax"], col='transparent', col.regions=qualPal)
Chloropleth mapsShades a region
f luniformlyaccording tomeasurementof a variable in that region.Here we useHere we use the results of the 2011 S i hSpanishgeneral elections, a data set called‘votes2011’. EachEachmunicipalityhas beenh d d b hshaded by the
winning party
Chloropleth mapsEachmunicipalityp yhas beenshaded by thewinningwinningparty’sfraction of thevotesvotes
New York Times, 22 July 2013
Interactive, open this page:http://www.nytimes.com/2013/07/22/business/in-climbing-income-ladder-location-matters.html
Raster mapsRaster is a matrix of cells coded with values of a variable, eitherquantitative (e.g., temperature, land use, population density), or
l ( l d h )categorical (e.g., land cover type, weather category,…)
Data set ‘SISav’Distribution of solar irradiation over the Iberian peninsula.
In R:
library(raster)
library(rasterVis)
SISav <- raster('data/SISav')
levelplot(SISav)
di (SIS )dim(SISav)
[1] 268 468 1
single layer
Level plot
Colour coded“heatmap” h i l lshowing levels
of irradiation.
Level plot, with map
Adding map ofAdding map of Spain usingpackages maps,
d dmapdata and maptools
Hill shading
Downloaded from biogeo.ucdavis.edu
Level plot, with hill shading
Adding hillAdding hillshading, withpartialtransparency(alpha=0.5)
3D plotting (& printing!)
# uses rgl packageplot3D(DEM, maxpixels=5e4)p prgl.snapshot(file="spain_hills.png")
# write on file that can be rendered on GitHub# STL (STereoLithography) format used for 3D printingwriteSTL('figs/DEM.stl')
Spatiotemporal (space-time) data
Can think of data as a collection of snapshots at different times.Can be displayed as a sequence of frames to produce an animation.Or a multipanel display on one page.
vector (pointsor polygons)- e.g., pollution
raster- e.g., satellitedata, highe.g., pollution
data, data fromfixed sensors, providing data b d t i ti
spatialresolution, butcould be sparsein timeabundant in time in time
See CRAN Task Views “Handling and Analyzing Spatiotemporal Data”http://cran.r-project.org/web/views/SpatioTemporal.html
R SIG Geo mailing listR-SIG-Geo mailing listhttps://stat.ethz.ch/mailman/listinfo/R-Sig-Geo/
R package spacetime
Built on classes and methods for spatial data from the sp package, and for time series from the xts package (extension of zoo).Four classes of space-time layouts:
STF STFDF STS STSDF STI STIDF STT STTDFSTF, STFDFFull space-time grid, all space-time combinations
STS, STSDFSparse space-time grid, stores onlynon-missing
STI, STIDFIrregular layout
STT, STTDFSimple trajectories
gcombinations
stConstruct creates space-time objects
aggregate aggregates data over spatial or temporal domainsgg g gg g p p
stplot plot spatio-temporal objects (multipanel plots, space-time plots,animations, time series plots
First 12 days of 2011of NO2 levels in MadridFirst 12 days of 2011of NO2 levels in Madrid# quite a lot of code preceding this!NO2st <- STFDF(airStations, index(NO2zoo), dats)
coordinates, time index, data vector(s)
dim(NO2st)space time variables
24 365 1 airPal <- colorRampPalette(c('springgreen1' 'sienna3' 'gray5'))(5)airPal <- colorRampPalette(c( springgreen1 , sienna3 , gray5 ))(5)stplot(NO2st[, 1:12], cuts=5, col.regions=airPal, edge.col='black')space-time plot of
first 12 days
Whole time series of NO2 levels in MadridWhole time series of NO2 levels in MadridEach column is a station (using last 2 digits of station code)
(white is NA value)Using some scaling method beforehand, the stations can be
ordered in a better way.
Some stations stay more or less constant throughout year
Some stations changing a lot throughout year
R packages raster and rasterVis
raster implements functions for raster data manipulation commonin geographic information systems (GIS)Raster* classes of raster objects:
RasterLayer RasterStack RasterBrickRasterLayerSingle-layer raster
RasterStackList of RasterLayerobjects, each withsame spatial extent
RasterBrickMore efficientmulti-layeredobjectp
and resolutionj
crop geographic subset of larger Raster* objectcrop geographic subset of larger Raster* object
merge merges two Raster* objects into one
projectRaster transform coordinates system of Raster* objectp j y j
cut replaces range of values with single values
zonal summarizes Raster* object into zones (areas with same integernumber) defined by another RasterLayer.
Daily solar radiation estimates in GaliciaSat_20110101 Sun_20110102 Mon_20110103 Tue_20110104 Wed_20110105 Thu_20110106 Fri_20110107 Sat_20110108
[1,] 33.42449 35.52649 18.19531 76.70464 41.73530 48.16842 74.86934 8.755703
[2,] 33.28713 34.55594 19.06866 76.70085 41.70245 48.26453 74.73301 8.061434[2,] 33.28713 34.55594 19.06866 76.70085 41.70245 48.26453 74.73301 8.061434
[3,] 33.57031 34.36150 20.24502 76.21733 41.80117 48.25137 74.87817 7.881998
[4,] 34.42028 35.21310 21.82977 75.08723 42.07725 48.09093 75.40273 8.396460
[5,] 35.27026 36.06470 23.41453 73.95713 42.35332 47.93050 75.92728 8.910922
[6,] 36.12024 36.91631 24.99928 72.82703 42.62939 47.77006 76.45182 9.425385
[7,] 36.97021 37.76791 26.58403 71.69692 42.90547 47.60963 76.97637 9.939847
[8,] 37.82019 38.61952 28.16879 70.56682 43.18154 47.44919 77.50092 10.454309
[9 ] 38 60471 39 30025 29 83628 69 58266 43 26163 47 26610 77 78446 11 184508[9,] 38.60471 39.30025 29.83628 69.58266 43.26163 47.26610 77.78446 11.184508
[10,] 39.14411 39.34106 31.81362 69.14510 42.60771 46.99814 77.16537 12.722667
library(raster); library(zoo); library(rasterVis)library(raster); library(zoo); library(rasterVis)
SISdm <- brick('data/SISgal')
dim(SISdm)70x95 values for
creates multilayer rasterBrick object
[1] 70 95 365
timeIndex <- seq(as.Date('2011-01-01'), by='day', length=365)
70x95 values foreach day in 2011
q , y y , g
SISdm <- setZ(SISdm, timeIndex)
names(SISdm) <- format(timeIndex, '%a_%Y%m%d')
adds time index
# level plot (first 12 days)
levelplot(SISdm, layers=1:12, panel=panel.levelplot.raster)
1-12 January 2011
Aggregation over monthsSISmm <- zApply(SISdm, by=as.yearmon, fun='mean')levelplot(SISmm, panel=panel.levelplot.raster)
Histograms for each month alsohistogram(SISdm, FUN=as.yearmon)
alsoas.yearqtr
Boxplots for each monthbwplot(SISdm, FUN=as.yearmon, violin=FALSE)
Violin boxplots for each monthbwplot(SISdm, FUN=as.yearmon)
Scatterplot matrix for monthssplom(SISmm, xlab='', plot.loess=TRUE)
Hovmoller plot for time serieshovmoller(SISdm, par.settings=BTCTheme())
BTC: one of the functions for returning colors
ll
hovmoller: a time series on a single spatial dimension by on perceptually
linear scales, where steps correspond to
d e s o byaggregation (in this case over longitude by default) correspond to
‘just detectable differences’ (see ColorRamps)
default)
Hovmoller plot for time serieshovmoller(SISdm, dirXY=x, par.settings=BTCTheme())
hovmoller: a time series on a single spatial dimension by d e s o byaggregation (in this case over latitude... Can be by anybe by any direction – see xyLayer)
Multivariate time series for each latitude bandxyplot(SISdm, digits=1, col='black', lwd=0.2, alpha=0.6)
each latitude band is a time seriestime series
Horizon plots for latitude bandshorizonplot(SISdm, digits=1,
col.regions=rev(brewer.pal(n=6, 'PuOr')),)xlab='', ylab='Latitude')