RWikience: introduction tutorial
All data in Climate Wikience are directly accessible from R using RWikience package |
RWikience package allows to retrieve raster, time series data from Climate Wikience to R and also contains related utility fuctions. Steps to get data into R:
- Download and install R from www.r-project.org/
- Download and install an IDE like RStudio www.rstudio.com/ide/
- Install rJava package (you will need this to run RWikience) You can install rJava by typing the following code in R console:
- Download RWikience package and install it into R
- Launch Climate Wikience (RWikience will work only when Climate Wikience is currently running)
install.packages(“rJava”) |
RWikience_path <- "path to where you downloaded RWikience package tar.gz"; install.packages(RWikience_path, repos = NULL, type = "source") # Example (use "/" or "\\" in Windows): RWikience_path <- "C:/Users/User/WikienceFiles/RWikience_1.1-0.tar.gz" install.packages(RWikience_path, repos = NULL, type = "source") |
The following two commands are required to start working with RWikience
# Load RWikience package library(RWikience) # Connect to running instance of Climate Wikience on your PC w<-WikienceConnect() |
To retrieve global maps (raster data), use getFloatMatrix function:
# Retrieve global matrix of NO2 concentration for 1-st of October 2004 m <- getFloatMatrix(w, "OMI.Nitrogen dioxide.ColumnAmountNO2TropCloudScreened", "01 10 2004") |
To enable many other ways of processing data, convert the matrix to “raster” type of “raster” package:
# Load "raster" package library(raster) # Convert to R type "raster" r <- convertToRaster(m) |
Simply type “r” to view the properties of newly created raster:
> r class : RasterLayer dimensions : 720, 1440, 1036800 (nrow, ncol, ncell) resolution : 0.25, 0.25 (x, y) extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax) coord. ref. : +proj=longlat +datum=WGS84 data source : in memory names : layer values : -6.343879e+15, 4.233803e+16 (min, max) |
Create 2-D map of the global NO2 distribution:
# Visualize raster plot(r) |
You can retrieve other maps in the same way:
m <- getFloatMatrix(w, "MERRA.Wind.Eastward (u).10 m", "01 08 2010") r <- convertToRaster(m) plot(r) m <- getFloatMatrix(w, "Modis L3 Atmosphere.AEROSOL.LAND AND OCEAN.Optical Depth.Maximum", "04 08 2005") r <- convertToRaster(m) plot(r) |
You can take a full dataset name to forward in to “getFloatMatrix” by simply activating it in Climate Wikience and copying its names from Time Slider drop-down box or Properties drop-down box.
R code used in this tutorial [wpdm_file id=7]
Archives
- February 2022 (1)
- May 2015 (1)
- April 2015 (1)
- February 2015 (8)
- January 2015 (4)
- November 2014 (5)
- October 2014 (4)
- May 2014 (4)
Tags
- Air pollution (1)
- Air pollution risk (1)
- AMSR-E (2)
- Aura Satellite (1)
- CFSR (3)
- Cloud top pressure (1)
- Cloud top temperature (1)
- Greeness fraction (1)
- Hurricane Katrina (5)
- IBTrACS (1)
- isolines (4)
- LAI (1)
- MERRA (1)
- MODIS (2)
- Nitrogen dioxide (2)
- OMI (2)
- QuikSCAT (2)
- RWikience (1)
- SSMIs (2)
- Time series (2)
- TMI (2)
- Wind speed (2)