Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of...
Transcript of Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of...
![Page 1: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/1.jpg)
Spatial Analysis and Visualization of Climate Data Using R
David SathiarajNOAA Southern Regional Climate Center
Louisiana State University
![Page 3: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/3.jpg)
ACIS
• ACIS - Applied Climate Information System (www.rcc-acis.org)
• Provides Storage, Access and Analysis of Climate Data
• 3 layer abstracted architecture - comprises of station meta data, climate data and derived product layers
• Data Source for generating maps
![Page 4: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/4.jpg)
DiskDiskDiskData
SetsMetadata
QC
Products
Real Time Feed
Data Synchronization
![Page 5: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/5.jpg)
Why R?
• Simple data structures
• Robust matrix computations
• Spatial libraries
• Visualization tools
![Page 6: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/6.jpg)
Map Generation Tools
• Color Selection - RColorBrewer
• Masking - sp
• Map Projection - mapproj
• Fitting and Modeling - fields, sp
![Page 7: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/7.jpg)
Mapping Climate Divisions
• Climate divisions shape file
usdiv = readShapePoly(“divisions.shp”)
plot(usdiv,col=brewer.pal(11, `Spectral’)
• Get a subset of climate divisions
• Choose Color (based on climate data)
• Plot and Draw legend !!"# !!!# !!## !$# !%# !&#
"#
'#
(#
)#
![Page 8: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/8.jpg)
Mapping Climate Divisions
• Get a subset of climate divisions
• Using subset command in R
• Choose Color (based on climate data)
• Plot and Draw legend
!!"# !!"" !$# !$" !%#
&#
'"
'#
("
![Page 9: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/9.jpg)
Mapping Climate Divisions
• Choose Color (based on climate data)
- colours <- brewer.pal(nclr,"RdYlGn")
- ratio<-(max(prcp)-min(prcp))/nclr
- brks<-round(seq(min(prcp),max(prcp), by=ratio),digits=0)
- colorIndx <- findInterval(prcp, brks, all.inside=T)
• Plot and Draw legend !!"# !!"" !$# !$" !%#
&#
'"
'#
("
)*+,-./01
)2.-./01
2005 Prcp Total: SRCC Divisions
![Page 10: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/10.jpg)
Mapping Climate Divisions
• Plot and Draw legend
- plot(srccdiv_shp, col=colours[colorIndx], xlab="Longitude", ylab="Latitude")
- title("2005 Prcp Total: SRCC Divisions")
- legend(-87.5, 30, legend=leglabs(brks), fill=colours, cex=1, bty="o")
!!"# !!"" !$# !$" !%#
&#
'"
'#
("
)*+,-./01
)2.-./01
2005 Prcp Total: SRCC Divisions
/+0134!%
!%4!4&'
&'4!4&$
&$4!4'(
'(4!4("
("4!4(#
(#4!4#"
#"4!4#5
*6134#5
![Page 11: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/11.jpg)
!!"# !!"" !$# !$" !%#
&#
'"
'#
("
)*+,-./01
)2.-./01
2005 Prcp Total: SRCC Divisions
/+0134!%
!%4!4&'
&'4!4&$
&$4!4'(
'(4!4("
("4!4(#
(#4!4#"
#"4!4#5
*6134#5
![Page 12: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/12.jpg)
Surface Fitting
• Fields package in R
• krig.image (from fields)
• tim.colors (from fields)
• Masking Routine
• Map projection
![Page 13: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/13.jpg)
Kriging using fields
fit=krig.image(xy,z,cov.function=Exp.image.cov,m=mx,n=nx,lambda=0.01,kmax=1000,expand=1.2)
res<- predict( fit, fit$xM) - fit$yM
img=list(fit$surface$x,fit$surface$y,fit$surface$z)
proj_pts = mapproject(list(x=img$x,y=img$y),projection="mercator")
proj_img = list(x=proj_pts$x,y=proj_pts$y,z=img$z)
proj_img = mask(proj_img)
image.plot(proj_img,col=rev(tim.colors(64)),xlab='Longitude',ylab='Latitude',add=1,projection="",horizontal=1)
![Page 14: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/14.jpg)
Masking
• Pass the array of fitted points to the masking routine
• Find which points lie ‘inside’ the polygon(I) and which lie ‘outside’ (O) - ‘inout’ method in the ‘sp’ package
• Nullify the ‘outside’ points, O
• one possibility is assign their ‘z’ values to NA
• Return the array comprising of nullified outside points, O and ‘inside’ points, I
![Page 15: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/15.jpg)
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
● ●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
● ●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●●
●
●
●
●
−95 −94 −93 −92 −91 −90 −89
3233
3435
3637
Longitude
Latitude
![Page 16: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/16.jpg)
![Page 17: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/17.jpg)
![Page 18: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/18.jpg)
![Page 19: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/19.jpg)
![Page 20: Spatial Analysis and Visualization of Climate Data Using R · Spatial Analysis and Visualization of Climate Data Using R David Sathiaraj NOAA Southern Regional Climate Center Louisiana](https://reader036.fdocuments.us/reader036/viewer/2022062605/5fd74d9f7d4e301ac4643dd1/html5/thumbnails/20.jpg)
Baton Rouge Ryan AirportT
em
pera
ture
[F
]
01 15 01 15 01 15 01 15 01 15 01 15 01 15 01 15 01 15 01 15 01 15 01 15
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
30
40
50
60
70
80
90
100
Pre
cip
itation [in
]
01 15 01 15 01 15 01 15 01 15 01 15 01 15 01 15 01 15 01 15 01 15 01 15
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2007
0
10
20
30
40
50
60
Charts using R