B BGU course 2024

Last updated: 2024-04-01 19:54:28

B.1 Course aims

  • General knowledge in programming
  • Overview of spatial data processing and analysis in R

B.2 Course details

  • Course number: 128.1.0043
  • Time: Sunday 16:10-19:00
  • Place: Building 72, room 249
  • Instructor: Michael Dorman ()
  • Grading: 4-5 exercises (50%) + exam (50%)
  • Requirements:
    • Basic knowledge of GIS (e.g., “Intro to GIS” course)
    • Self study
  • Getting help:

B.3 Lecture plan

Lesson Date Chapter Exercise
01 2024-05-05 The R environment (Chapter 1)
02 2024-05-12 Vectors (Chapter 2) Exercise 1 (Appendix C)
03 2024-05-19 Time series and function definitions (Chapter 3)
04 2024-05-26 Tables, conditionals and loops (Chapter 4) Exercise 2 (Appendix D)
05 2024-06-02 Matrices and rasters (Chapter 5)
06 2024-06-09 Raster processing (Chapter 6) Exercise 3 (Appendix E)
07 2024-06-16 Vector layers (Chapter 7)
08 2024-06-23 Geometric operations with vector layers (Chapter 8) Exercise 4 (Appendix F)
09 2024-06-30 Geometric operations with rasters (Chapter 9)
10 2024-07-07 Combining rasters and vector layers (Chapter 10) Exercise 5 (Appendix G)
11 - Processing spatio-temporal data (Chapter 11)
12 - Spatial interpolation of point data (Chapter 12) Exercise 6 (Appendix H)
13 2024-07-14 Exam questions

B.4 Exercise submission dates

Exercise Date
Exercise 1 (Appendix C) 2024-05-26
Exercise 2 (Appendix D) 2024-06-09
Exercise 3 (Appendix E) 2024-06-23
Exercise 4 (Appendix F) 2024-07-07
Exercise 5 (Appendix G) -
Exercise 6 (Appendix H) -

B.5 Exercise instructions

B.5.1 Guidelines

  • Submission is through Moodle only
  • The submission should be a single R code file
  • File name is your last name + exercise number, in English, such as dorman_01.R
  • The code needs to run as is, assuming that:
    • All required packages are installed
    • All data files are in the user’s working directory
  • Do not include install.packages expressions
  • Do not include setwd expressions
  • Do include library expressions
  • Self-check:
    • Start a new R session
    • Manually set the working directory to where the data files are
    • Run the entire script
  • Late submission up to -20%, and additional -10% per week, unless coordinated in advance
  • The code file should include the exercise number, your first name and last name (as comments), and mark the relevant code sections for each question (using comments). The necessary library expressions can be placed at the beginning of the script. For example:
# Exercise 01
# Michael Dorman

library(stars)

# Question 01
r = read_stars("MOD13A3_2000_2019.tif")
plot(r[,,,1])

# Question 02
...

B.5.2 Generality

  • The code needs to be as general as possible:
    • Do not use specific values except the ones given in the question
    • When there are intermediate results—assign them to a variable and use the variable, not the value
  • Question: what is the last value of c(5,3,1,7,2,3,2,6)?
  • Good solution:
x = c(5,3,1,7,2,3,2,6)
x[length(x)]
## [1] 6
  • Bad solution:
x = c(5,3,1,7,2,3,2,6)
x[8]
## [1] 6

B.5.3 Brackets

  • Use brackets to make sure the right order of operations is done
  • Question: print the subset of the last four values in c(5,3,1,7,2,3,2,6)
  • Correct solution:
x = c(5,3,1,7,2,3,2,6)
x[(length(x)-3):length(x)]
## [1] 2 3 2 6
  • Wrong solution:
x = c(5,3,1,7,2,3,2,6)
x[length(x)-3:length(x)]
## [1] 2 7 1 3 5

B.5.4 Required value or output

  • Note which outputs or printouts are requested

B.5.5 Packages

  • You can use any other R packages, even those we didn’t learn about, as long as:
    • They are in the official repository (CRAN), i.e., can be installed with install.packages
    • Your script returns the requested outputs

B.6 Resources

B.6.1 Books: General

  • Murrell, P. (2010). Introduction to Data Technologies. Chapman and Hall/CRC. [PDF] [Website]
  • Wickham, H. (2014). Advanced R. Chapman and Hall/CRC. [HTML]

B.6.2 Books: Spatial data

  • Hengl, T. (2009). A Practical Guide to Geostatistical Mapping. [PDF]
  • Lovelace, R., Nowosad, J., Muenchow, J. (2019). Geocomputation with R. Chapman and Hall/CRC. [HTML]
  • Pebesma, E., Bivand, R. (in preparation). Spatial Data Science. [HTML]