Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

R crash course

on

  • 4,453 views

The following presentation contains some basic introduction materials for R beginners.

The following presentation contains some basic introduction materials for R beginners.

Statistics

Views

Total Views
4,453
Views on SlideShare
4,447
Embed Views
6

Actions

Likes
3
Downloads
125
Comments
0

2 Embeds 6

http://www.linkedin.com 4
https://www.linkedin.com 2

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-NonCommercial LicenseCC Attribution-NonCommercial License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    R crash course R crash course Presentation Transcript

    • R crash course T. Hengl & R.S. Bivand R crash course Overview Course programme (for people who pick up new methods/tools quickly Why R? Software installation and have a high motivation to learn) Scripting in R Do’s and don’ts R code editors Working with T. Hengl1 & R.S. Bivand2 spatial data Spatial classes Spatial methods 1 Instituut voor Biodiversiteit en Ecosysteem Dynamica R+SAGA R+FWTools Universiteit van Amsterdam Export to Google Earth 2 Department of Economics Literature Norwegian School of Economics and Business administration June 19, 2010
    • Outline R crash course 1 Overview T. Hengl & R.S. Bivand Course programme Overview Why R? Course programme Software installation Why R? Software installation 2 Scripting in R Scripting in R Do’s and don’ts Do’s and don’ts R code editors R code editors Working with spatial data Spatial classes 3 Working with spatial data Spatial methods R+SAGA Spatial classes R+FWTools Export to Google Spatial methods Earth R+SAGA Literature R+FWTools Export to Google Earth 4 Literature
    • Programme R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Software installation Scripting in R Installation and first (baby) steps (intro.R). Do’s and don’ts R code editors Building, running and editing models in R. Working with spatial data Working with spatial data. Spatial classes Spatial methods R+SAGA R+FWTools Export to Google Earth Literature
    • Crash course R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Software installation A “crash course” is a compressed version of a training course for Scripting in R people that already have full agendas. It is really intended for Do’s and don’ts R code editors people who pick up new methods/tools quickly and have a high Working with motivation to learn (PhD students?). This means no long spatial data Spatial classes questions, no going back, no long discussion, no complains Spatial methods about the speed/programme of the course. . . and of course: no R+SAGA R+FWTools promises that you will manage to learn R in such a short time. Export to Google Earth Literature
    • The course programme R crash course Basic concepts (self-study) T. Hengl & R.S. Bivand R basic and add-on packages; Overview R syntax; R objects and ’methods’; Course programme Why R? R FAQs; getting help and the most important literature; Software installation Scripting in R Scripting in R Do’s and don’ts R code editors data management; creating and debugging scripts Working with (scripting editors: Tinn-R); spatial data Spatial classes automating analysis — making functions and packages; Spatial methods R+SAGA publication quality outputs (using R+Sweave); R+FWTools Export to Google Earth Advanced topics Literature GDAL and R; spatial classes and packages; calling external applications from R (SAGA GIS, FWTools, Python, Matlab; export of maps to Google Earth;
    • Outline R crash course 1 Overview T. Hengl & R.S. Bivand Course programme Overview Why R? Course programme Software installation Why R? Software installation 2 Scripting in R Scripting in R Do’s and don’ts Do’s and don’ts R code editors R code editors Working with spatial data Spatial classes 3 Working with spatial data Spatial methods R+SAGA Spatial classes R+FWTools Export to Google Spatial methods Earth R+SAGA Literature R+FWTools Export to Google Earth 4 Literature
    • Getting the right motivation (inspiration) R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Software installation What is R, and why should you invest time to learn it? Scripting in R Do’s and don’ts What can it do? (and what it can’t do?) R code editors Working with How does the R community works (what are its shared spatial data principles)? Spatial classes Spatial methods R+SAGA Is R suited for spatio-temporal data analysis? R+FWTools Export to Google Earth Literature
    • Some important assumptions R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Software installation R is (increasingly) sexy. Scripting in R Do’s and don’ts R is hell. R code editors You are all beginners (who need a gentle intro). Working with spatial data Spatial classes You are non-statisticians / computer scientists. Spatial methods R+SAGA I learned R myself. If I can do it, you can do it too. R+FWTools Export to Google Earth Literature
    • Some important assumptions R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Software installation R is (increasingly) sexy. Scripting in R Do’s and don’ts R is hell. R code editors You are all beginners (who need a gentle intro). Working with spatial data Spatial classes You are non-statisticians / computer scientists. Spatial methods R+SAGA I learned R myself. If I can do it, you can do it too. R+FWTools Export to Google Earth Literature
    • Some important assumptions R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Software installation R is (increasingly) sexy. Scripting in R Do’s and don’ts R is hell. R code editors You are all beginners (who need a gentle intro). Working with spatial data Spatial classes You are non-statisticians / computer scientists. Spatial methods R+SAGA I learned R myself. If I can do it, you can do it too. R+FWTools Export to Google Earth Literature
    • Some important assumptions R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Software installation R is (increasingly) sexy. Scripting in R Do’s and don’ts R is hell. R code editors You are all beginners (who need a gentle intro). Working with spatial data Spatial classes You are non-statisticians / computer scientists. Spatial methods R+SAGA I learned R myself. If I can do it, you can do it too. R+FWTools Export to Google Earth Literature
    • Some important assumptions R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Software installation R is (increasingly) sexy. Scripting in R Do’s and don’ts R is hell. R code editors You are all beginners (who need a gentle intro). Working with spatial data Spatial classes You are non-statisticians / computer scientists. Spatial methods R+SAGA I learned R myself. If I can do it, you can do it too. R+FWTools Export to Google Earth Literature
    • What is R? R crash course T. Hengl & the open source implementation of the S language for R.S. Bivand statistical computing created by created by Ross Ihaka Overview and Robert Gentleman (now maintained by the R Course programme Why R? Development Core Team); Software installation Scripting in R why R?: the name “R” was selected for two reasons: (1) Do’s and don’ts precedence — “R” is a letter before “S”, and (2) coincidence R code editors Working with — both of the creators’ names start with a letter “R” ; spatial data Spatial classes it is a computer language developed to simplify statistical Spatial methods R+SAGA computing/programming; R+FWTools Export to Google it offers many contributed packages, technical documents, Earth demos and examples; Literature widely recognized as one of the fastest growing and most comprehensive statistical computing tools; it is a movement;
    • What is R? R crash course T. Hengl & the open source implementation of the S language for R.S. Bivand statistical computing created by created by Ross Ihaka Overview and Robert Gentleman (now maintained by the R Course programme Why R? Development Core Team); Software installation Scripting in R why R?: the name “R” was selected for two reasons: (1) Do’s and don’ts precedence — “R” is a letter before “S”, and (2) coincidence R code editors Working with — both of the creators’ names start with a letter “R” ; spatial data Spatial classes it is a computer language developed to simplify statistical Spatial methods R+SAGA computing/programming; R+FWTools Export to Google it offers many contributed packages, technical documents, Earth demos and examples; Literature widely recognized as one of the fastest growing and most comprehensive statistical computing tools; it is a movement;
    • What is R? R crash course T. Hengl & the open source implementation of the S language for R.S. Bivand statistical computing created by created by Ross Ihaka Overview and Robert Gentleman (now maintained by the R Course programme Why R? Development Core Team); Software installation Scripting in R why R?: the name “R” was selected for two reasons: (1) Do’s and don’ts precedence — “R” is a letter before “S”, and (2) coincidence R code editors Working with — both of the creators’ names start with a letter “R” ; spatial data Spatial classes it is a computer language developed to simplify statistical Spatial methods R+SAGA computing/programming; R+FWTools Export to Google it offers many contributed packages, technical documents, Earth demos and examples; Literature widely recognized as one of the fastest growing and most comprehensive statistical computing tools; it is a movement;
    • What is R? R crash course T. Hengl & the open source implementation of the S language for R.S. Bivand statistical computing created by created by Ross Ihaka Overview and Robert Gentleman (now maintained by the R Course programme Why R? Development Core Team); Software installation Scripting in R why R?: the name “R” was selected for two reasons: (1) Do’s and don’ts precedence — “R” is a letter before “S”, and (2) coincidence R code editors Working with — both of the creators’ names start with a letter “R” ; spatial data Spatial classes it is a computer language developed to simplify statistical Spatial methods R+SAGA computing/programming; R+FWTools Export to Google it offers many contributed packages, technical documents, Earth demos and examples; Literature widely recognized as one of the fastest growing and most comprehensive statistical computing tools; it is a movement;
    • What is R? R crash course T. Hengl & the open source implementation of the S language for R.S. Bivand statistical computing created by created by Ross Ihaka Overview and Robert Gentleman (now maintained by the R Course programme Why R? Development Core Team); Software installation Scripting in R why R?: the name “R” was selected for two reasons: (1) Do’s and don’ts precedence — “R” is a letter before “S”, and (2) coincidence R code editors Working with — both of the creators’ names start with a letter “R” ; spatial data Spatial classes it is a computer language developed to simplify statistical Spatial methods R+SAGA computing/programming; R+FWTools Export to Google it offers many contributed packages, technical documents, Earth demos and examples; Literature widely recognized as one of the fastest growing and most comprehensive statistical computing tools; it is a movement;
    • What is R? R crash course T. Hengl & the open source implementation of the S language for R.S. Bivand statistical computing created by created by Ross Ihaka Overview and Robert Gentleman (now maintained by the R Course programme Why R? Development Core Team); Software installation Scripting in R why R?: the name “R” was selected for two reasons: (1) Do’s and don’ts precedence — “R” is a letter before “S”, and (2) coincidence R code editors Working with — both of the creators’ names start with a letter “R” ; spatial data Spatial classes it is a computer language developed to simplify statistical Spatial methods R+SAGA computing/programming; R+FWTools Export to Google it offers many contributed packages, technical documents, Earth demos and examples; Literature widely recognized as one of the fastest growing and most comprehensive statistical computing tools; it is a movement;
    • R is “sexy” R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Software installation Scripting in R Do’s and don’ts R code editors Working with spatial data Spatial classes Spatial methods R+SAGA R+FWTools Export to Google Earth Literature
    • Quote R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Software installation “ R has really become the second language for people Scripting in R coming out of grad school now, and there’s an Do’s and don’ts R code editors amazing amount of code being written for it.” Working with spatial data Spatial classes Spatial methods Max Kuhn R+SAGA R+FWTools Export to Google Earth Literature
    • What it is NOT R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? it’s not a software with GUI and point-and-click control; Software installation there are practically no data analysis wizards; Scripting in R Do’s and don’ts it’s not an interactive system; R code editors Working with it comes with no warranties (but so does the commercial spatial data Spatial classes software too!!); Spatial methods R+SAGA there is practically no formal support; R+FWTools Export to Google Earth however. . . Literature
    • What it is NOT R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? it’s not a software with GUI and point-and-click control; Software installation there are practically no data analysis wizards; Scripting in R Do’s and don’ts it’s not an interactive system; R code editors Working with it comes with no warranties (but so does the commercial spatial data Spatial classes software too!!); Spatial methods R+SAGA there is practically no formal support; R+FWTools Export to Google Earth however. . . Literature
    • What it is NOT R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? it’s not a software with GUI and point-and-click control; Software installation there are practically no data analysis wizards; Scripting in R Do’s and don’ts it’s not an interactive system; R code editors Working with it comes with no warranties (but so does the commercial spatial data Spatial classes software too!!); Spatial methods R+SAGA there is practically no formal support; R+FWTools Export to Google Earth however. . . Literature
    • What it is NOT R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? it’s not a software with GUI and point-and-click control; Software installation there are practically no data analysis wizards; Scripting in R Do’s and don’ts it’s not an interactive system; R code editors Working with it comes with no warranties (but so does the commercial spatial data Spatial classes software too!!); Spatial methods R+SAGA there is practically no formal support; R+FWTools Export to Google Earth however. . . Literature
    • What it is NOT R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? it’s not a software with GUI and point-and-click control; Software installation there are practically no data analysis wizards; Scripting in R Do’s and don’ts it’s not an interactive system; R code editors Working with it comes with no warranties (but so does the commercial spatial data Spatial classes software too!!); Spatial methods R+SAGA there is practically no formal support; R+FWTools Export to Google Earth however. . . Literature
    • What it is NOT R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? it’s not a software with GUI and point-and-click control; Software installation there are practically no data analysis wizards; Scripting in R Do’s and don’ts it’s not an interactive system; R code editors Working with it comes with no warranties (but so does the commercial spatial data Spatial classes software too!!); Spatial methods R+SAGA there is practically no formal support; R+FWTools Export to Google Earth however. . . Literature
    • Why make scripts? R crash course T. Hengl & R.S. Bivand It’s easy to use: “Because S (and its implementation R) is a well-developed, simple and effective programming Overview Course programme language which includes conditionals, loops, user-defined Why R? Software installation recursive functions and input and output facilities, existing Scripting in R functions can be modified.” In R we all become Do’s and don’ts R code editors programmers (but much faster than with C++ or Java). Working with spatial data The basic approach to using R is to generate scripts that Spatial classes define the data processing steps (workflows?). Spatial methods R+SAGA R+FWTools Documenting the analysis process is a “good thing” so, Export to Google Earth programming scripts are not just a burden, certainly for Literature users doing original research and repetitive work, arguably for student classes too. Point-and-click operations are for amateurs.
    • Why make scripts? R crash course T. Hengl & R.S. Bivand It’s easy to use: “Because S (and its implementation R) is a well-developed, simple and effective programming Overview Course programme language which includes conditionals, loops, user-defined Why R? Software installation recursive functions and input and output facilities, existing Scripting in R functions can be modified.” In R we all become Do’s and don’ts R code editors programmers (but much faster than with C++ or Java). Working with spatial data The basic approach to using R is to generate scripts that Spatial classes define the data processing steps (workflows?). Spatial methods R+SAGA R+FWTools Documenting the analysis process is a “good thing” so, Export to Google Earth programming scripts are not just a burden, certainly for Literature users doing original research and repetitive work, arguably for student classes too. Point-and-click operations are for amateurs.
    • Why make scripts? R crash course T. Hengl & R.S. Bivand It’s easy to use: “Because S (and its implementation R) is a well-developed, simple and effective programming Overview Course programme language which includes conditionals, loops, user-defined Why R? Software installation recursive functions and input and output facilities, existing Scripting in R functions can be modified.” In R we all become Do’s and don’ts R code editors programmers (but much faster than with C++ or Java). Working with spatial data The basic approach to using R is to generate scripts that Spatial classes define the data processing steps (workflows?). Spatial methods R+SAGA R+FWTools Documenting the analysis process is a “good thing” so, Export to Google Earth programming scripts are not just a burden, certainly for Literature users doing original research and repetitive work, arguably for student classes too. Point-and-click operations are for amateurs.
    • Why make scripts? R crash course T. Hengl & R.S. Bivand It’s easy to use: “Because S (and its implementation R) is a well-developed, simple and effective programming Overview Course programme language which includes conditionals, loops, user-defined Why R? Software installation recursive functions and input and output facilities, existing Scripting in R functions can be modified.” In R we all become Do’s and don’ts R code editors programmers (but much faster than with C++ or Java). Working with spatial data The basic approach to using R is to generate scripts that Spatial classes define the data processing steps (workflows?). Spatial methods R+SAGA R+FWTools Documenting the analysis process is a “good thing” so, Export to Google Earth programming scripts are not just a burden, certainly for Literature users doing original research and repetitive work, arguably for student classes too. Point-and-click operations are for amateurs.
    • Do you speak R? R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Software installation Scripting in R After some time you basically discovered that most of the things Do’s and don’ts R code editors you want to do, you can do in R, the only question is how. Working with spatial data Well, first, you have to learn to how to speak’n’write R. Spatial classes Spatial methods R+SAGA R+FWTools Export to Google Earth Literature
    • Why NOT Matlab? R crash course T. Hengl & R.S. Bivand R and Matlab are in fact very similar, except. . . : Overview (almost) everything you do in Matlab, you can do in R; Course programme Why R? R can be used to write homework (for Matlab you need a Software installation computer lab with software licences); Scripting in R Do’s and don’ts “R gradually pushes people towards better programming R code editors habits” (Tam´s K. Papp); a Working with spatial data Spatial classes Matlab has a limited support for processing spatial data (R Spatial methods R+SAGA is better); R+FWTools Export to Google Contributed packages in R are growing faster (R is better); Earth Literature We are in academia — we shouldn’t be developing toolboxes for some private company but for the people (and for ourselves);
    • A bit of history R crash course T. Hengl & R.S. Bivand R was first time released in 1997; Overview majority of the development is (still) done by prof. Brian Course programme Why R? D. Ripley; Software installation Scripting in R a the moment (juni 19 2010 10:01), there are 2387 Do’s and don’ts contributed packages! R code editors Working with according to Google trends, R-project.org has a spatial data Spatial classes community of about 200–350k active users; Spatial methods R+SAGA in 2003, a group of researchers (International Workshop on R+FWTools Export to Google Distributed Statistical Computing) decided to add Spatial Earth functionality to R; Literature . . . now is time to use it more broadly (MSc level and PhD level modules, projects, reports and scientific documents);
    • Quote R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? “Once methodological problems start being perceived Software installation or even defined in terms of what one’s favorite Scripting in R software does well, then the software has stopped Do’s and don’ts R code editors being a tool, and has become a crutch, and at worse a Working with spatial data shackle.” Spatial classes Spatial methods R+SAGA R+FWTools Simon Jackman Export to Google Earth Literature
    • The ASDA(R)-book.org R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Software installation Scripting in R Do’s and don’ts R code editors Working with spatial data Spatial classes Spatial methods R+SAGA R+FWTools Export to Google Earth Literature
    • The ASDA(R) team R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Software installation Scripting in R Do’s and don’ts R code editors Working with spatial data Spatial classes Spatial methods R+SAGA R+FWTools Export to Google Earth Literature
    • A Practical Guide to Geostatistical Mapping R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Software installation Scripting in R Do’s and don’ts R code editors Working with spatial data Spatial classes Spatial methods R+SAGA R+FWTools Export to Google Earth Literature
    • Quote R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Software installation “I created Quick-R for one simple reason. I wanted to Scripting in R learn R and I am a teacher at heart. The easiest way Do’s and don’ts R code editors for me to learn something is to teach it” Working with spatial data Spatial classes Spatial methods Robert I. Kabacoff R+SAGA R+FWTools Export to Google Earth Literature
    • Outline R crash course 1 Overview T. Hengl & R.S. Bivand Course programme Overview Why R? Course programme Software installation Why R? Software installation 2 Scripting in R Scripting in R Do’s and don’ts Do’s and don’ts R code editors R code editors Working with spatial data Spatial classes 3 Working with spatial data Spatial methods R+SAGA Spatial classes R+FWTools Export to Google Spatial methods Earth R+SAGA Literature R+FWTools Export to Google Earth 4 Literature
    • Software R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Not all software is required to follow the exercises Software installation Scripting in R R v2.11 (Windows OS) including a list of packages; Do’s and don’ts R code editors Tinn-R v2.3 (code editor); Working with spatial data Optional: FWTools v2.4 — a list of utilities to handle Spatial classes Spatial methods spatial data; SAGA GIS v2.0.4 — a light GIS excellent for R+SAGA educational purposes. R+FWTools Export to Google Earth Literature
    • Installing the add-on packages R crash course T. Hengl & R.S. Bivand Overview > install.packages("ctv") Course programme > library(ctv) Why R? Software installation > install.views("Spatial") Scripting in R Do’s and don’ts R code editors Working with spatial data Spatial classes Spatial methods This will install all connected packages listed at R views Spatial. R+SAGA R+FWTools Export to Google Earth Literature
    • Check your installation R crash course T. Hengl & R.S. Bivand Overview > Sys.getenv(c("OS", "COMPUTERNAME", "R_HOME", "R_LIBS_USER", Course programme Why R? + "PROCESSOR_IDENTIFIER")) Software installation OS Scripting in R "Windows_NT" Do’s and don’ts R code editors COMPUTERNAME "PC-IBED193" Working with spatial data R_HOME Spatial classes "C:PROGRA~1RR-210~1.1" Spatial methods R_LIBS_USER R+SAGA "n:/R/win-library/2.10" R+FWTools Export to Google PROCESSOR_IDENTIFIER Earth "x86 Family 6 Model 15 Stepping 6, GenuineIntel" Literature
    • Outline R crash course 1 Overview T. Hengl & R.S. Bivand Course programme Overview Why R? Course programme Software installation Why R? Software installation 2 Scripting in R Scripting in R Do’s and don’ts Do’s and don’ts R code editors R code editors Working with spatial data Spatial classes 3 Working with spatial data Spatial methods R+SAGA Spatial classes R+FWTools Export to Google Spatial methods Earth R+SAGA Literature R+FWTools Export to Google Earth 4 Literature
    • Making friends with R R crash course T. Hengl & 1 Use script editors such as as TINN-R or JGR (syntax R.S. Bivand highlighting, wrapping, search/replace etc.). Overview 2 The best way to learn R is to look at the existing scripts, Course programme Why R? then extend: Software installation Graphical Manual/Addicted to R — if you prefer to explore Scripting in R Do’s and don’ts examples graphically; R code editors Teach-your-self books e.g. “Statistics with R” or “An Working with Introduction to R” “Introduction to R for ITC students” ; spatial data Spatial classes Quick-R and/or R by example; Spatial methods R+SAGA 3 If your R script does not work, do not break your head, try R+FWTools Export to Google to get help: Earth local installation: > help.search("kriging"); Literature R-project: > RSiteSearch("krige dimensions do not match") www: Rseek.org R mailing lists;
    • Making friends with R R crash course T. Hengl & 1 Use script editors such as as TINN-R or JGR (syntax R.S. Bivand highlighting, wrapping, search/replace etc.). Overview 2 The best way to learn R is to look at the existing scripts, Course programme Why R? then extend: Software installation Graphical Manual/Addicted to R — if you prefer to explore Scripting in R Do’s and don’ts examples graphically; R code editors Teach-your-self books e.g. “Statistics with R” or “An Working with Introduction to R” “Introduction to R for ITC students” ; spatial data Spatial classes Quick-R and/or R by example; Spatial methods R+SAGA 3 If your R script does not work, do not break your head, try R+FWTools Export to Google to get help: Earth local installation: > help.search("kriging"); Literature R-project: > RSiteSearch("krige dimensions do not match") www: Rseek.org R mailing lists;
    • Making friends with R R crash course T. Hengl & 1 Use script editors such as as TINN-R or JGR (syntax R.S. Bivand highlighting, wrapping, search/replace etc.). Overview 2 The best way to learn R is to look at the existing scripts, Course programme Why R? then extend: Software installation Graphical Manual/Addicted to R — if you prefer to explore Scripting in R Do’s and don’ts examples graphically; R code editors Teach-your-self books e.g. “Statistics with R” or “An Working with Introduction to R” “Introduction to R for ITC students” ; spatial data Spatial classes Quick-R and/or R by example; Spatial methods R+SAGA 3 If your R script does not work, do not break your head, try R+FWTools Export to Google to get help: Earth local installation: > help.search("kriging"); Literature R-project: > RSiteSearch("krige dimensions do not match") www: Rseek.org R mailing lists;
    • Making friends with R R crash course T. Hengl & 1 Use script editors such as as TINN-R or JGR (syntax R.S. Bivand highlighting, wrapping, search/replace etc.). Overview 2 The best way to learn R is to look at the existing scripts, Course programme Why R? then extend: Software installation Graphical Manual/Addicted to R — if you prefer to explore Scripting in R Do’s and don’ts examples graphically; R code editors Teach-your-self books e.g. “Statistics with R” or “An Working with Introduction to R” “Introduction to R for ITC students” ; spatial data Spatial classes Quick-R and/or R by example; Spatial methods R+SAGA 3 If your R script does not work, do not break your head, try R+FWTools Export to Google to get help: Earth local installation: > help.search("kriging"); Literature R-project: > RSiteSearch("krige dimensions do not match") www: Rseek.org R mailing lists;
    • Making friends with R R crash course T. Hengl & 1 Use script editors such as as TINN-R or JGR (syntax R.S. Bivand highlighting, wrapping, search/replace etc.). Overview 2 The best way to learn R is to look at the existing scripts, Course programme Why R? then extend: Software installation Graphical Manual/Addicted to R — if you prefer to explore Scripting in R Do’s and don’ts examples graphically; R code editors Teach-your-self books e.g. “Statistics with R” or “An Working with Introduction to R” “Introduction to R for ITC students” ; spatial data Spatial classes Quick-R and/or R by example; Spatial methods R+SAGA 3 If your R script does not work, do not break your head, try R+FWTools Export to Google to get help: Earth local installation: > help.search("kriging"); Literature R-project: > RSiteSearch("krige dimensions do not match") www: Rseek.org R mailing lists;
    • Making friends with R R crash course T. Hengl & 1 Use script editors such as as TINN-R or JGR (syntax R.S. Bivand highlighting, wrapping, search/replace etc.). Overview 2 The best way to learn R is to look at the existing scripts, Course programme Why R? then extend: Software installation Graphical Manual/Addicted to R — if you prefer to explore Scripting in R Do’s and don’ts examples graphically; R code editors Teach-your-self books e.g. “Statistics with R” or “An Working with Introduction to R” “Introduction to R for ITC students” ; spatial data Spatial classes Quick-R and/or R by example; Spatial methods R+SAGA 3 If your R script does not work, do not break your head, try R+FWTools Export to Google to get help: Earth local installation: > help.search("kriging"); Literature R-project: > RSiteSearch("krige dimensions do not match") www: Rseek.org R mailing lists;
    • Making friends with R R crash course T. Hengl & 1 Use script editors such as as TINN-R or JGR (syntax R.S. Bivand highlighting, wrapping, search/replace etc.). Overview 2 The best way to learn R is to look at the existing scripts, Course programme Why R? then extend: Software installation Graphical Manual/Addicted to R — if you prefer to explore Scripting in R Do’s and don’ts examples graphically; R code editors Teach-your-self books e.g. “Statistics with R” or “An Working with Introduction to R” “Introduction to R for ITC students” ; spatial data Spatial classes Quick-R and/or R by example; Spatial methods R+SAGA 3 If your R script does not work, do not break your head, try R+FWTools Export to Google to get help: Earth local installation: > help.search("kriging"); Literature R-project: > RSiteSearch("krige dimensions do not match") www: Rseek.org R mailing lists;
    • Making friends with R R crash course T. Hengl & 1 Use script editors such as as TINN-R or JGR (syntax R.S. Bivand highlighting, wrapping, search/replace etc.). Overview 2 The best way to learn R is to look at the existing scripts, Course programme Why R? then extend: Software installation Graphical Manual/Addicted to R — if you prefer to explore Scripting in R Do’s and don’ts examples graphically; R code editors Teach-your-self books e.g. “Statistics with R” or “An Working with Introduction to R” “Introduction to R for ITC students” ; spatial data Spatial classes Quick-R and/or R by example; Spatial methods R+SAGA 3 If your R script does not work, do not break your head, try R+FWTools Export to Google to get help: Earth local installation: > help.search("kriging"); Literature R-project: > RSiteSearch("krige dimensions do not match") www: Rseek.org R mailing lists;
    • Making friends with R R crash course T. Hengl & 1 Use script editors such as as TINN-R or JGR (syntax R.S. Bivand highlighting, wrapping, search/replace etc.). Overview 2 The best way to learn R is to look at the existing scripts, Course programme Why R? then extend: Software installation Graphical Manual/Addicted to R — if you prefer to explore Scripting in R Do’s and don’ts examples graphically; R code editors Teach-your-self books e.g. “Statistics with R” or “An Working with Introduction to R” “Introduction to R for ITC students” ; spatial data Spatial classes Quick-R and/or R by example; Spatial methods R+SAGA 3 If your R script does not work, do not break your head, try R+FWTools Export to Google to get help: Earth local installation: > help.search("kriging"); Literature R-project: > RSiteSearch("krige dimensions do not match") www: Rseek.org R mailing lists;
    • Making friends with R R crash course T. Hengl & 1 Use script editors such as as TINN-R or JGR (syntax R.S. Bivand highlighting, wrapping, search/replace etc.). Overview 2 The best way to learn R is to look at the existing scripts, Course programme Why R? then extend: Software installation Graphical Manual/Addicted to R — if you prefer to explore Scripting in R Do’s and don’ts examples graphically; R code editors Teach-your-self books e.g. “Statistics with R” or “An Working with Introduction to R” “Introduction to R for ITC students” ; spatial data Spatial classes Quick-R and/or R by example; Spatial methods R+SAGA 3 If your R script does not work, do not break your head, try R+FWTools Export to Google to get help: Earth local installation: > help.search("kriging"); Literature R-project: > RSiteSearch("krige dimensions do not match") www: Rseek.org R mailing lists;
    • Good practice R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Put comments in script (after #). Software installation Scripting in R Add some meta-information at the beginning of your Do’s and don’ts script. R code editors Working with Once you tested your script and saw that it works, tidy-up spatial data Spatial classes the code. Spatial methods R+SAGA Place the input data on-line (database) so you can R+FWTools Export to Google communicate only the script. Earth Literature
    • R mailing lists: Do’s and Don’ts! R crash course Do’s: T. Hengl & R.S. Bivand If you have not done so already, read the R posting guide. Use the existing pre-installed data sets (come together with Overview Course programme a certain package) to describe your problem; link your Why R? Software installation problem to some existing problems. Scripting in R Acknowledge the work (time spent) other people do to help Do’s and don’ts you. R code editors You can submit not only the problems you discover but also Working with spatial data the information that you think is interesting for the Spatial classes community. Spatial methods R+SAGA Don’ts: R+FWTools Export to Google Earth Do not send poorly formulated questions. Literature Do not send too much. Complaining to a mailing list about what frustrates you about R makes no sense. You are requesting that somebody does a work for you that you could do yourself!
    • Outline R crash course 1 Overview T. Hengl & R.S. Bivand Course programme Overview Why R? Course programme Software installation Why R? Software installation 2 Scripting in R Scripting in R Do’s and don’ts Do’s and don’ts R code editors R code editors Working with spatial data Spatial classes 3 Working with spatial data Spatial methods R+SAGA Spatial classes R+FWTools Export to Google Spatial methods Earth R+SAGA Literature R+FWTools Export to Google Earth 4 Literature
    • Tinn-R R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Software installation Scripting in R Do’s and don’ts R code editors Working with spatial data Spatial classes Spatial methods R+SAGA R+FWTools Export to Google Earth Literature
    • JaGuaR R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Software installation Scripting in R Do’s and don’ts R code editors Working with spatial data Spatial classes Spatial methods R+SAGA R+FWTools Export to Google Earth Literature
    • Outline R crash course 1 Overview T. Hengl & R.S. Bivand Course programme Overview Why R? Course programme Software installation Why R? Software installation 2 Scripting in R Scripting in R Do’s and don’ts Do’s and don’ts R code editors R code editors Working with spatial data Spatial classes 3 Working with spatial data Spatial methods R+SAGA Spatial classes R+FWTools Export to Google Spatial methods Earth R+SAGA Literature R+FWTools Export to Google Earth 4 Literature
    • Spatial objects R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? An advantage of R (as compared to e.g. Matlab) is that you Software installation can create your own formats and structures for data. But if Scripting in R Do’s and don’ts there are too many formats you can easily get lots. In addition, R code editors we want to have smooth links to external formats (R is open!). Working with spatial data Spatial classes Spatial methods R+SAGA R+FWTools To reduce this problem, Bivand et al. (2008) developed Export to Google Earth new-style classes to represent spatial data. Literature
    • Spatial class R crash course T. Hengl & R.S. Bivand Overview The foundation object is the Spatial class, with just two basic Course programme Why R? slots (new-style S classes have pre-defined components called Software installation slots): Scripting in R Do’s and don’ts a bounding box — mostly used for setting up plots; R code editors Working with a CRS class object — defining the coordinate reference spatial data Spatial classes system, and may be set to CRS(as.character(NA)); Spatial methods R+SAGA Operations on Spatial* objects should update or copy these R+FWTools Export to Google values to the new Spatial* objects being created. The most Earth Literature basic spatial data object is a point, which may have 2 or 3 dimensions.
    • Spatial classes R crash course T. Hengl & R.S. Bivand Overview Course programme for point features: SpatialPoints; Why R? Software installation SpatialPointsDataFrame; Scripting in R Do’s and don’ts for line features: SpatialLines, R code editors SpatialLinesDataFrame; Working with spatial data polygons: SpatialPolygons, Spatial classes Spatial methods SpatialPolygonsDataFrame; R+SAGA R+FWTools rasters: SpatialPixels, SpatialPixelsDataFrame, Export to Google Earth SpatialGrid, SpatialGridDataFrame; Literature
    • SpatialPoints R crash course T. Hengl & R.S. Bivand Overview > library(sp) Course programme Why R? > data(meuse) Software installation > coords <- SpatialPoints(meuse[, c("x", "y")]) Scripting in R > summary(coords) Do’s and don’ts R code editors Object of class SpatialPoints Coordinates: Working with spatial data min max Spatial classes x 178605 181390 Spatial methods y 329714 333611 R+SAGA Is projected: NA R+FWTools Export to Google proj4string : [NA] Earth Number of points: 155 Literature
    • SpatialPointsDataFrame R crash course T. Hengl & R.S. Bivand We can add the tabular data to make a Overview Course programme SpatialPointsDataFrame object: Why R? Software installation Scripting in R Do’s and don’ts > meuse1 <- SpatialPointsDataFrame(coords, meuse) R code editors > str(meuse1, max.level = 2) Working with spatial data Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots Spatial classes ..@ data :'data.frame': 155 obs. of 14 variables: Spatial methods ..@ coords.nrs : num(0) R+SAGA ..@ coords : num [1:155, 1:2] 181072 181025 181165 ... R+FWTools Export to Google .. ..- attr(*, "dimnames")=List of 2 Earth ..@ bbox : num [1:2, 1:2] 178605 329714 181390 333611 Literature .. ..- attr(*, "dimnames")=List of 2 ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
    • Point features R crash Spatial points classes and their slots course T. Hengl & R.S. Bivand ments Overview Course programme Why R? SpatialPointsDataFrame Spatial Software installation SpatialPoints bbox Scripting in R Do’s and don’ts coords.nrs proj4string R code editors data Working with spatial data SpatialPoints Spatial classes Spatial methods data.frame coords R+SAGA Spatial R+FWTools Export to Google Earth Literature Spatial lines and polygons
    • Line/polygon features Spatial Polygons classes and slots R crash course T. Hengl & SpatialLines Lines Line dge Bivand R.S. lines Lines coords ma Overview Spatial ID ns programme Course Why R? Software installation Scripting in R Do’s and don’ts SpatialPolygons Polygons Polygon R code editors Working with spatial data polygons Polygons labpt Spatial classes plotOrder plotOrder area Spatial methods R+SAGA Spatial labpt hole ID R+FWTools Export to Google ringDir area coords Earth Literature Spatial bbox proj4string
    • Grids R crash Spatial grid and pixels classes and their slots course e bank & T. Hengl R.S. Bivand he data SpatialGridDataFrame GridTopology m Overview the Course programme SpatialGrid SpatialGrid cellcentre.offset Why R? data grid cellsize Software installation grid.index cells.dim Scripting in R Do’s and don’ts SpatialPoints R code editors Spatial Working with SpatialPixelsDataFrame bbox spatial data SpatialPixels SpatialPixels proj4string Spatial classes Spatial methods data grid R+SAGA grid.index SpatialPoints R+FWTools Export to Google SpatialPoints coords Earth Spatial Literature data.frame Spatial classes provided by sp
    • Outline R crash course 1 Overview T. Hengl & R.S. Bivand Course programme Overview Why R? Course programme Software installation Why R? Software installation 2 Scripting in R Scripting in R Do’s and don’ts Do’s and don’ts R code editors R code editors Working with spatial data Spatial classes 3 Working with spatial data Spatial methods R+SAGA Spatial classes R+FWTools Export to Google Spatial methods Earth R+SAGA Literature R+FWTools Export to Google Earth 4 Literature
    • Basic methods R crash course T. Hengl & R.S. Bivand spplot — plotting of spatial objects (maps); Overview Course programme spsample — sample points from a set of polygons, on a Why R? Software installation set of lines or from a gridded area; Scripting in R Do’s and don’ts bbox — get the bounding box; R code editors proj4string — get or set the projection (coordinate Working with spatial data reference system); Spatial classes Spatial methods R+SAGA coordinates — set or retrieve coordinates; R+FWTools Export to Google spTransform — transform coordinates from one CRS to Earth another; Literature overlay — combine two different spatial objects;
    • Plotting a SpatialPoints object R crash course T. Hengl & R.S. Bivand > plot(as(meuse1, "Spatial"), axes = TRUE) > plot(meuse1, add = TRUE) Overview > plot(meuse1[meuse1$ffreq == 1, ], col = "green", add = TRUE) Course programme Why R? Software installation Scripting in R Do’s and don’ts 333000 R code editors Working with spatial data 332000 Spatial classes Spatial methods 331000 R+SAGA R+FWTools 330000 Export to Google Earth Literature 178000 179000 180000 181000 182000
    • Combining statistical and GIS operations R crash course T. Hengl & R.S. Bivand Because the Spatial*DataFrame family objects behave in Overview Course programme most cases like data frames, most of what we are used to Why R? Software installation doing with standard data frames just works (but no merge, Scripting in R etc., yet). Do’s and don’ts R code editors These objects are very similar to typical representations of Working with the same kinds of objects in geographical information spatial data Spatial classes systems, so they do not suit spatial data that is not Spatial methods R+SAGA geographical (like medical imaging) as such. R+FWTools Export to Google Earth Because now sp classes for GIS data exits, this opens the Literature door for fusing GIS and statistical operations (this has not been possible in e.g. 2002).
    • Spatial packages R crash course T. Hengl & R.S. Bivand Overview R now offers a range of contributed packages in spatial Course programme Why R? statistics and increasing awareness of the importance of spatial Software installation data analysis in the broader community. Current contributed Scripting in R Do’s and don’ts packages with spatial applications: R code editors point patterns: spatstat, VR:spatial, splancs; Working with spatial data Spatial classes geostatistics: gstat, geoR, geoRglm, fields, spBayes, Spatial methods RandomFields, VR:spatial, sgeostat, vardiag; R+SAGA R+FWTools Export to Google lattice/area data: spdep, DCluster, spgwr, ade4; Earth Literature links to GIS: rgdal, spgrass, RPy, RSAGA;
    • Let’s create spatial objects! R crash course T. Hengl & R.S. Bivand Overview We can create spatial objects from scratch! For example a Course programme Why R? DEM: Software installation Scripting in R Do’s and don’ts R code editors > dem <- expand.grid(x = seq(100, 600, 100), y = seq(100, Working with + 600, 100)) spatial data > dem$Z <- as.vector(c(23, 24, 34, 38, 45, 51, 24, 20, Spatial classes + 20, 28, 18, 49, 22, 20, 19, 14, 38, 45, 19, 15, 13, Spatial methods + 21, 23, 25, 14, 11, 18, 11, 18, 19, 10, 16, 23, 16, R+SAGA R+FWTools + 9, 6)) Export to Google > gridded(dem) <- ~x + y Earth > dem <- as(dem, "SpatialGridDataFrame") Literature > str(dem)
    • A small DEM R crash course T. Hengl & R.S. Bivand > dem.plt <- spplot(dem[1], main = "DEM", scales = list(draw = FALSE), + col.regions = topo.colors(25)) Overview > print(dem.plt) Course programme > writeGDAL(dem, "dem6.sdat", "SAGA") Why R? Software installation DEM Scripting in R Do’s and don’ts 50 R code editors Working with 40 spatial data Spatial classes Spatial methods 30 R+SAGA R+FWTools Export to Google 20 Earth Literature 10
    • Outline R crash course 1 Overview T. Hengl & R.S. Bivand Course programme Overview Why R? Course programme Software installation Why R? Software installation 2 Scripting in R Scripting in R Do’s and don’ts Do’s and don’ts R code editors R code editors Working with spatial data Spatial classes 3 Working with spatial data Spatial methods R+SAGA Spatial classes R+FWTools Export to Google Spatial methods Earth R+SAGA Literature R+FWTools Export to Google Earth 4 Literature
    • Controlling SAGA from R R crash course T. Hengl & R.S. Bivand Overview > library(RSAGA) Course programme > rsaga.env() Why R? Software installation $workspace Scripting in R [1] "." Do’s and don’ts R code editors $cmd Working with [1] "saga_cmd.exe" spatial data Spatial classes Spatial methods $path R+SAGA [1] "C:/PROGRA~1/R/R-210~1.1/library/RSAGA/saga_vc" R+FWTools Export to Google Earth $modules [1] "C:/PROGRA~1/R/R-210~1.1/library/RSAGA/saga_vc/modules" Literature
    • Getting list of modules R crash course T. Hengl & R.S. Bivand Overview Course programme > rsaga.get.modules("ta_channels") Why R? Software installation $ta_channels Scripting in R code name interactive Do’s and don’ts 1 0 Channel Network FALSE R code editors 2 1 Watershed Basins FALSE Working with 3 2 Watershed Basins (extended) FALSE spatial data Spatial classes 4 3 Vertical Distance to Channel Network FALSE Spatial methods 5 4 Overland Flow Distance to Channel Network FALSE R+SAGA 6 5 D8 Flow Analysis FALSE R+FWTools 7 6 Strahler Order FALSE Export to Google Earth Literature
    • Run stream extraction R crash course > rsaga.geoprocessor(lib = "ta_channels", module = 5, param = list(DEM = " T. Hengl & + DIRECTION = "channels.sgrd", CONNECTION = "route.sgrd", R.S. Bivand + NETWORK = "channels.shp")) Overview SAGA CMD 2.0.4 Course programme Why R? Software installation library path: C:/PROGRA~1/R/R-210~1.1/library/RSAGA/... library name: ta_channels Scripting in R module name : D8 Flow Analysis Do’s and don’ts R code editors author : (c) 2003 by O.Conrad Working with spatial data Load grid: dem6.sgrd... Spatial classes ready Spatial methods R+SAGA Parameters R+FWTools Export to Google Grid system: 100; 6x 6y; 100x 100y Earth DEM: dem6 Literature Flow Direction: Flow Direction Flow Connectivity: Flow Connectivity Flow Network: Flow Network Minimum Connectivity: 0 ...
    • Read back to R R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? > dem$route <- readGDAL("route.sdat")$band1 Software installation Scripting in R route.sdat has GDAL driver SAGA Do’s and don’ts and has 6 rows and 6 columns R code editors Working with > channels <- readOGR("channels.shp", "channels") spatial data Spatial classes OGR data source with driver: ESRI Shapefile Spatial methods Source: "channels.shp", layer: "channels" R+SAGA with 32 features and 2 fields R+FWTools Export to Google Feature type: wkbLineString with 2 dimensions Earth Literature
    • Plot the final result R crash course T. Hengl & R.S. Bivand > dem.plt <- spplot(dem[1], main = "DEM", col.regions = topo.colors(25)) > channels.plt <- spplot(dem[2], col.regions = rev(gray(0:20/20)), Overview + main = "Flow connectivity", sp.layout = list("sp.lines", Course programme Why R? + channels, col = "red")) Software installation > print(dem.plt, split = c(1, 1, 2, 1), more = T) Scripting in R > print(channels.plt, split = c(2, 1, 2, 1), more = F) Do’s and don’ts DEM Flow connectivity R code editors 4.0 50 Working with 3.5 spatial data 40 Spatial classes 3.0 Spatial methods 2.5 R+SAGA 30 2.0 R+FWTools Export to Google 1.5 Earth 20 1.0 Literature 0.5 10 0.0
    • Outline R crash course 1 Overview T. Hengl & R.S. Bivand Course programme Overview Why R? Course programme Software installation Why R? Software installation 2 Scripting in R Scripting in R Do’s and don’ts Do’s and don’ts R code editors R code editors Working with spatial data Spatial classes 3 Working with spatial data Spatial methods R+SAGA Spatial classes R+FWTools Export to Google Spatial methods Earth R+SAGA Literature R+FWTools Export to Google Earth 4 Literature
    • Preparing FWTools R crash course T. Hengl & R.S. Bivand Overview Course programme There is still no package to control FWTools from R, but we can Why R? Software installation simply send command lines using the system command. Before Scripting in R we can use FWTools from R, we need to locate it on our PC: Do’s and don’ts R code editors Working with spatial data Spatial classes > gdalwarp <- gsub("/", "", dir(path="C:/PROGRA~2/FWTOOL~1.7", Spatial methods + pattern="gdalwarp.exe", recursive=TRUE, full.names=TRUE)) R+SAGA > gdalwarp R+FWTools Export to Google [1] "C:PROGRA~2FWTOOL~1.7bingdalwarp.exe" Earth > workd <- paste(gsub("/", "", getwd()), "", sep="") Literature
    • MODIS data R crash course Now we can download some GIS data from web: T. Hengl & R.S. Bivand > MOD12Q1 <- "ftp://anonymous:test@e4ftl01u.ecs.nasa.gov/ + MOLT/MOD12Q1.004/2004.01.01/" Overview > download.file(paste(MOD12Q1, Course programme Why R? + "MOD12Q1.A2004001.h18v03.004.2006117173748.hdf", sep=""), Software installation + destfile=paste(getwd(), + "MOD12Q1.A2004001.h18v03.004.2006117173748.hdf", sep="/"), Scripting in R Do’s and don’ts + mode='wb', method='wget') R code editors Resolving e4ftl01u.ecs.nasa.gov... 152.61.4.83 Working with Connecting to e4ftl01u.ecs.nasa.gov|152.61.4.83|:21... connected. spatial data Spatial classes Logging in as anonymous ... Logged in! Spatial methods ==> SYST ... done. ==> PWD ... done. R+SAGA ==> TYPE I ... done. ==> CWD /MOLT/MOD12Q1.004/2004.01.01 ... done. R+FWTools Export to Google ==> SIZE MOD12Q1.A2004001.h18v03.004.2006117173748.hdf ... 23165983 Earth ==> PASV ... done. ==> RETR MOD12Q1.A2004... done. Literature Length: 23165983 (22M) 0K .......... .......... 0% 64.9K 5m48s ... 22550K .......... .......... 99% 501K 0s 22600K .......... 100% 503K=65s
    • Reprojecting grids R crash course T. Hengl & We can reproject/resample the map to our local coordinate R.S. Bivand system using the gdalwarp functionality (this combines several Overview Course programme processing steps in one function): Why R? Software installation > NL.prj <- "+proj=sterea +lat_0=52.15616055555555 Scripting in R + +lon_0=5.38763888888889 +k=0.999908 +x_0=155000 Do’s and don’ts + +y_0=463000 +ellps=bessel +units=m +no_defs R code editors + +towgs84=565.237,50.0087,465.658, Working with + -0.406857,0.350733,-1.87035,4.0812" spatial data Spatial classes > system(paste(gdalwarp, " HDF4_EOS:EOS_GRID:"", workd, Spatial methods + "MOD12Q1.A2004001.h18v03.004.2006117173748.hdf" R+SAGA + :MOD12Q1:Land_Cover_Type_1 -t_srs "", NL.prj, "" R+FWTools Export to Google + IGBP2004NL.tif -r near -te 0 300000 280000 625000 Earth + -tr 500 500", sep="")) Literature Creating output file that is 560P x 650L. Processing input file HDF4_EOS:EOS_GRID:MOD12Q1.A2004001... Using internal nodata values (eg. 255) for image HDF4_EOS:EOS_... 0...10...20...30...40...50...60...70...80...90...100 - done.
    • Plot the final result R crash course In this case we have produced a MODIS-based land cover map T. Hengl & for the whole Netherlands in resolution of 500 m (in local R.S. Bivand coordinate system). Overview Course programme Why R? Software installation Scripting in R Do’s and don’ts R code editors Working with spatial data Spatial classes Spatial methods R+SAGA R+FWTools Export to Google Earth Literature
    • Outline R crash course 1 Overview T. Hengl & R.S. Bivand Course programme Overview Why R? Course programme Software installation Why R? Software installation 2 Scripting in R Scripting in R Do’s and don’ts Do’s and don’ts R code editors R code editors Working with spatial data Spatial classes 3 Working with spatial data Spatial methods R+SAGA Spatial classes R+FWTools Export to Google Spatial methods Earth R+SAGA Literature R+FWTools Export to Google Earth 4 Literature
    • Writing spatial data to KML R crash course T. Hengl & R.S. Bivand Overview Course programme Why R? Software installation There are two possibilities to export maps to KML: (a) Scripting in R using existing packages, and (b) by writing KML files Do’s and don’ts R code editors “by-hand” . Working with To export point or line features to KML, use the writeOGR spatial data Spatial classes method that is available in R package rgdal. Spatial methods R+SAGA More flexible way to writing KML files is by using loops. R+FWTools Export to Google Earth Literature
    • Literature R crash course T. Hengl & R.S. Bivand Overview Bivand, R., Pebesma, E., Rubio, V., 2008. Applied Spatial Course programme Data Analysis with R. Use R Series, Springer, Heidelberg, Why R? Software installation 378 p. Scripting in R Do’s and don’ts Hengl, T., 2009. A Practical Guide to Geostatistical R code editors Mapping, 2nd edition. University of Amsterdam, 291 p. Working with spatial data ISBN 978-90-9024981-0. Spatial classes Spatial methods Kabacoff, R.I., 2009. Data Analysis and Graphics with R. R+SAGA R+FWTools Manning publications, 375 p. Export to Google Earth Literature Zuur, A. F., Ieno, E. N., Meesters, E. H. W. G., 2009. A Beginner’s Guide to R. Springer, Use R series, 228 p.