--- title: "First Steps in RGeostats" author: "RGeostats Team" date: "September 2019" output: slidy_presentation: default ioslides_presentation: default beamer_presentation: colortheme: beaver fig_height: 3.5 fig_width: 3.5 theme: Boadilla fontsize: 8pt theme: Boadilla colortheme: beaver --- \frametitle{Loading Library} ```{r setup,echo=FALSE} library(knitr) ``` In each R session, you must load the **RGeostats** library ```{r Load_library, include=FALSE} library(RGeostats) ``` Clean the contents of your workspace ```{r Cleaning_WorkSpace} rm(list=ls()) ``` --- \frametitle{Main Classes} This is the (non-exhaustive) list of classes (of objects) in RGeostats: * db: numerical data base * vario: experimental variograms (vardir) * model: variogram model (melem) * neigh: neighborhood * anam: gaussian anamorphosis * polygon: 2-D polygonal shapes (polyset) * rule: lithotype rule for thresholds (truncated plurigaussian models) --- \frametitle{Loading_Data_File} You should download the ASCII file called *Scotland_Temperatures.csv* (organized as a CSV file) and store it on your disk in the current working directory, then convert it into a *Db*. Instead, you can download it (from the standard distribution) using the *rg.load* facility. It is named **dat**: the target variable is **January_temp** ```{r Loading_Data} rg.load("Exdemo_Scotland_Temperatures","dat",flag.overwrite=TRUE) dat = db.locate(dat,"January*","z") ``` --- \frametitle{Db class} Typing the name of the (R) object automatically launches the **print** action (i.e. launching **db.print** function): ```{r Other_printouts, eval=FALSE} print(dat) db.print(dat) ``` Check the description of the function (i.e. dbplot) by typing the following command. Note that the line has been commented in order to allow processing in batch. ```{r Interactive_Help, eval=FALSE} cat("Chunk is suppressed for batch processing") #?db.print ``` --- \frametitle{Db class} The following sentences are equivalent and demonstrate the different ways to designate one or several attributes of a Db: ```{r Prints,eval=FALSE} print(dat,flag.stats=T,names=4) print(dat,flag.stats=T,names="Elevation") print(dat,flag.stats=T,names="Elev*") ``` --- \frametitle{Assessors for Db class} Using the data frame internal organization: ```{r Using_bracket_assessors,eval=FALSE} dat[] ``` Looking for the fourth field specifically: ```{r Using_bracket_assessor_selective} dat[,4] ``` ```{r Using_assesors_with_names, eval=FALSE} dat[,"Elevation"] dat[,"*lev*"] ``` --- \frametitle{Assessors for Db class} List of all assessors available (valid for any class) ```{r Dumping_assessors} dat$all ``` --- \frametitle{Assessors for Db class} ```{r Local_assessors} dat$nsamples dat$natt ``` Check the geographical extension of the data set: ```{r Getting_Space_Limits} dat$limits dat$ndim ``` --- \frametitle{Locators for Db} ```{r Help_on_locators} cat("Chunk is suppressed for batch processing") #?db.locate ``` Set the variables 2 and 3 as coordinates : ```{r Setting_X_locators} dat = db.locate(dat,2:3,"x") ``` Set the variables 4 and 5 as the target regionalized variables : ```{r Setting_Z_locator} dat = db.locate(dat,4:5,"z") ``` --- \frametitle{Locators for Db} Check the locator modification: ```{r Printout} print(dat,flag.resume=FALSE) ``` Unset the variable 4 (**Elevation**): ```{r Deleting_locator} dat=db.locate(dat,4) ``` Which promotes **January_temp** as the first regionalized variable: ```{r Print_again,eval=FALSE} print(dat,flag.resume=FALSE) ``` --- \frametitle {Plotting a Db} Plot the contents of a Db using **plot** function (alias for **db.plot**). The proportional (defaulted) option applies to **z1** variable ```{r Plotting,fig.align="center"} plot(dat) ``` --- \frametitle {Plotting a Db} Use the same scales on both axes: *isometric* option ```{r Plotting_in_scale,fig.align="center"} plot(dat,asp=1) ``` --- \frametitle {Plotting a Db} Set the *isometric* option in the environment. Define other options for the plot. ```{r Setting_isometric_as_constant,fig.align="center"} constant.define("asp",1) plot(dat,title="Temperature",pch=21,col="blue",bg="yellow") ``` --- \frametitle {Plotting a Db} Use the **name** option to modify the displayed variable. ```{r Plotting_with_decoration,fig.align="center"} plot(dat,pch=21,col="blue",bg="yellow",name="Elevation") ``` --- \frametitle{Digital Elevation Model} Load the Digital Elevation Model into another Db. Its name within the distribution kit is **Exdemo_Scotland_Elevations**. In your working space, it will be named **db.grid** ```{r Loading_Elevation} rg.load("Exdemo_Scotland_Elevations","db.grid") ``` The Db is organized as a regular 2-D grid (checked using assessors): ```{r Asking_from_Map_limits} db.grid$ndim db.grid$flag.grid ``` --- \frametitle{Digital Elevation Model} ```{r Printing_grid_contents} print(db.grid,flag.extend=TRUE) ``` --- \frametitle{Selections in Db} The file **db.grid** contains the field **inshore** which corresponds to a **selection**. Only 3094 (out of 11097) samples (nodes) are **active** (represented in green in the plot of the grid) ```{r Plotting_inshore,fig.align="center"} plot(db.grid,name="inshore") ``` --- \frametitle{Selections in Db} We create a selection on the file **dat**, by supressing samples located beyond latitude 1100: active samples in yellow, masked samples in black. ```{r Display_using_selection, fig.align="center"} plot(db.grid,name="inshore") plot(dat,pch=19,col="black",add=T) dat=db.sel(dat,Latitude<1100) plot(dat,pch=21,col="blue",bg="yellow",add=T) ```