knitr::opts_chunk$set(echo = TRUE) knitr::opts_chunk$set(fig.path = './doc/Figure/')
This document explains the analytic capabilities of the IDEAS data model.
library(DBI) library(dplyr) library(sf) con = dbConnect(RNetezza::Netezza(), dsn='NZSQL')
We connect to a table containing spatial-time series of annual extreme daily climate variables for entire Canada.
data=tbl(con,"ANUSPLINE3") head(data)
Next we slice the data set for annual maximum daily precipitation.
datap=data%>%filter(KEY=='PRECIPITATION') head(datap)
We will calculate time-series of spatial average
avgs=datap%>%group_by(TID)%>%arrange(TID)%>%summarise(VALUE=mean(VALUE)) head(avgs)
We will calculate spatial distribution of temporal average
avgt=datap%>%group_by(DGGID)%>%arrange(DGGID)%>%summarise(VALUE=mean(VALUE)) head(avgt)
Let us plot some of these basic variables.
avgs=collect(avgs) plot(avgs$TID,avgs$VALUE)
To plot the spatial variable we need to attach it with the spatial tabls.
grid=tbl(con,"FINALGRID2") head(grid)
avgt=avgt%>%inner_join(grid,by=c('DGGID'))%>%mutate(WKT=inza..ST_AsText(GEOM))%>% select(DGGID,VALUE,WKT)%>%arrange(DGGID)%>%head(100)%>%collect() poly=st_as_sf(avgt, wkt='WKT', crs = 4326) plot(poly['VALUE'])
Lets get a little more complex now. We want to clip the data for one of the eco-zone over Canada say somwhere over BC, Pacific-Maritime (ecozone=13)
ecozone=tbl(con,"ECOZONE_12")%>%filter(VALUE==13)%>%select(DGGID) head(ecozone)
datape=datap%>%inner_join(ecozone,by=c('DGGID')) head(datape)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.