opengeodata.de

Matera - Day 4

2017-06-22

The course gets split up in basic R and advanced R users for the morning.

Session 1 - R basics

rm(a) - remove variable
gc() - clean RAM (garbage collector)
?<command> - get help on command (with examples)
q() - quite R
system("pwd") - run system command
data.frame=read.table("filename") - read something from outside into R into data frame 
str(data.frame) - show structure
$ - indicates another level, e.g. landuse04$landuse
head(data.frame) - show head of data frame
object.size(dem) - show byte size of data frame
dem$X=as.character(dem$X) - change data type of 'X' in 'dem' data frame to character
save(landuse04, file="~/landuse2004.Rdata") - save data frame as file
save.image() - save whole workspace
load("~landuse2004.Rdata")
rm(list = ls()) - remove everything in workspace
plot(landuse$fallow.Fallow, landuse$vineyard.Vineyards) - crude plotting
landuse[1:3 , 3:10] - access data via indices; first value pair = rows; second value pair = columns
install.packages("raster")
library(raster)
myinput=raster("/home/user/ost4sem/exercise/basic_adv_gdalogr/input.tif")
plot(myinput)
    -- install raster package, load it, load file and plot the raster
    -- raster is being kept in file instead of memory
    
@ - sub-level indicator for raster images    

Session 2 - conference call

Session 3 - R basics / distribution modelling

rbind(presence,absence) - join two tables   
table(points$PA) - count occurences of attribute
na - handle missing values (omit, fail, etc.)
c - combine values into list or vector

Session 4 - GRASS basics

grass70 -text ~/ost4sem/grassdb/europe/PERMANENT - start GRASS in textmode and load location 'europe' in 'grassdb'
r.info --ui - runs the r.info function (info about a layer) and starts the GUI dialogue for it
g.copy rast=potveg_ita@Vmodel,pvegita - copy within GRASS
g.remove -f type=raster name=pvegita - remove raster dataset
g.region -p - get current region 
g.region n=6015390 e=5676400 s=3303955 w=3876180 res 1000 save=scandinavia --overwrite - set new region
g.region res=20000 -p - change resolution
g.gui tcltk - bring up GUI (possible arguments for GUI wxpython,text,gtext on this particular machine)

g.list type=rast -p - list all raster maps (-p for pretty printing)

# We can open a monitor and display a raster 
g.region rast=fnfpc
d.mon start=x0
d.rast fnfpc

# and do the same thing for theother maps in different monitors
d.mon start=x1    
d.rast fnfpc_alpine10k 

# get input into GRASS
r.in.gdal input=~/ost4sem/exercise/basic_adv_grass/inputs/lc_cor2000/hdr.adf  output=landcover 

Session 5 - remote sensing & machine learning