Archaeological Spatial Analysis in R

Michal Michalski, Durham University

Welcome !

Me:

Michal Michalski

https://topographos.github.io/

Lessons and Code:

https://github.com/topographos/asar

Schedule

The classes will be in MCS1007, the new Maths and Science Building in Upper Mountjoy1.

Practical session every Friday (11 - 13.30)

  • 17th February - Intro to R and R-Spatial

  • 24th February - Vector based analysis

  • 3rd March - Raster based analysis

  • 10th March - Vector Raster interaction

Format

# focus on learnig by doing
asar <- class_material %>% # I will prepare material for each class
  live_coding() %>%  # as in Data Carpentries
  feedback() %>% # ask questions - I will take notes
  update() %>% # I will update material and add resources
  share() # I will share it as html, pdf
  • classes is generally built around book Gecomputation with R.1

  • although some additional resources are included (e.g.Intro to R)

Assesment

# practical
assesment <- class_material %>% # you will re-use your material
  data() %>%  # I will share new data with you
  analysis() %>% # you will read, wrangle, analyse and visualize data
  report(500) %>% # You will  write a short report 
  
# score
score <- assesment %>% 
  reproducibility() %>% # the analysis should be reproducible
  folder_structure() %>% 
  style() %>% # variables names, use of space tabs
  narrative() %>%  # e.g., clear comments explaining code and workflow
  analysis() %>% # accuracy - code should work as intended
  report()  # explanation of deployed method, clear figures formatting

The summative deadline for project delivery will be 12pm, Monday 24th April 2023, via Turnitin.

Archaeological Spatial Analysis

“The main aim of this work is to suggest to archaeologists that there is a potential for more detailed and systematic study of spatial patterning in archaeological data.”

(Hodder and Orton, 1976, p1.)

Spatial Analysis1

  • Spatial data manipulation - usually in GIS

  • Spatial data analysis - descriptive and exploratory

  • Spatial statistical analysis - deploy statistical methods

  • Spatial modelling - construct models to predict outcomes

Why R? .Global_Env

Tool - Driven Revolution in Archaeological Science 1

Schmidt and Marwick, Fig 1 and 2.

Why R? .Global_Env

Tool - Driven Revolution in Archaeological Science 1

  • ecology has moved much earlier to open programming such as R

  • archaeology have yet to adapt programming

  • we should update training curricula

  • emerging researcher in archaeology should be proficient in programming / analysis to collaborate with other domains (but not necessarily an expert in computer science)

Why R? .Local_Env

  • It is a great resource for data analysis, data visualization, data science and machine learning
  • It provides many statistical techniques
  • It is easy to draw graphs in R, histograms, box plot etc..
  • It works on different platforms (Windows, Mac, Linux)
  • It is open-source and free
  • It has a large community support
  • It has many packages (libraries of functions)

source: w3schools

Why R? .Local_Env

  • R integrates space and time (better than GIS)
  • seamless workflows for spatial and non-spatial analysis
  • GIS bridges
  • automation and reproducibility
  • literate programming

case study: https://topographos.github.io/banea/index.html

Coding Time ! - Lesson 0

R-spatial

CRAN Task View: Analysis of Spatial Data - link

Historical Background

Talk: A practical history of R-sig-geo by Roger Bivand

Article: Bivand, R.S. Progress in the R ecosystem for representing and handling spatial data. J Geogr Syst 23, 515–546 (2021).

Vector

Source: Pebesma E, Bivand R, Spatial Data Science, Figure 1.7.

Raster

Source: Roelandt N, Nowosad J, Getting Started with R and R-spatial, workshop FOSS4G2022 Fig 2.4.

Coding Time ! - Lesson 1

Vector - analysis

Learning Objectives

  • learn about simple feature package

  • deal with coordinate reference system

  • create vector objects

  • manipulate vector objects

Background Reading

  • Lovelace R, Nowosad K, Muenchow J, Geocomputation with R, Chapter 2.2, 2.4, 3.2, 4.2 and 5.2 - link

Vector analysis

Source (https://r.geocompx.org/spatial-class.html#intro-sf)

Vector analysis

Source (https://r-spatial.github.io/sf/articles/sf1.html) NOTE: update the image

point-in-polygon (PIP)

buffer geometries

dissolve geometries

voronoi polygons

Coding Time ! - Lesson 2

Raster - analysis

Learning Objectives

  • learn about raster class in terra package

  • deal with coordinate reference system

  • create raster objects

  • manipulate raster objects

Background Reading

  • Lovelace R, Nowosad K, Muenchow J, Geocomputation with R, Chapter 2.2, 2.4, 3.2, 4.2 and 5.2 - link

Raster

Map Algebra

Terrain Characterisitcs

Spectral Indices

GIS Bridges

Whitebox https://www.whiteboxgeo.com/

Geomorohons (Source:https://grass.osgeo.org/grass82/manuals/r.geomorphon.html)

Coding Time ! - Lesson 3

Raster - Vector

Learning Objectives

  • learn about raster extraction

  • visualize data using ggplot

Background Reading

  • Lovelace R, Nowosad K, Muenchow J, Geocomputation with R, Chapter 6 - link

Grammar of Graphics

Literate Programming

‘By coining the phrase “literate programming”, I am imposing a moral commitment on everyone who hears the term; surely nobody wants to admit writing an illiterate program’

Donald E. Knuth

https://quarto.org/docs/get-started/

Coding Time ! - Lesson 4

Assessment

ASAR Project

https://github.com/topographos/asar_project/

  • Q&A

  • Surgery (Zoom / Teams Call) in two weeks time?