# Spatial data analysis with R
Link to this page: siili.rahtiapp.fi/Rspatial_23
---
### :link: Links
* Coursepage: https://ssl.eventilla.com/rspatial_23
* Materials and exercises: https://github.com/csc-training/r-spatial-course
* CSC Notebooks: https://notebooks.csc.fi/
---
### :calendar: Program
All times Helsinki summer time, that is EEST (UTC+3).
**Wednesday 10.05.2023**
9:00-10:30 Handling and plotting vector data in R
10:45-12:00 Handling and plotting cont.
13:00-14:30 Spatial operations (intersection, clipping, conversions etc)
14:45-16:00 Spatial operations cont.
**Thursday 11.05.2023**
9:00-10:30 Spatial analysis of vector data (clustering, density surfaces, autocorrelation)
10:45-12:00 Spatial analysis cont.
13:00-14:15 Visualizing spatial data
14:30-16:00 Raster basics with R
**Friday 12.05.2023**
9:00-10:30 Raster data manipulation
10:45-12:00 Map algebra
13:00-14:30 Spatial modelling with raster data
14:45-15:30 Intro Spatio-Temporal Asset Catalogs (STAC) and how to use them from R. Kylli Ek (CSC)
15:30-16:00 [Mini-intro to possibilities of using R in CSC's supercomputer Puhti](https://a3s.fi/gis-courses/r_spatial/2305_Rspatial.html). Samantha Wittke (CSC)
---
### Course environment
1) Go to https://notebooks.csc.fi/
2) Finnish university and research institute users should be able to login with Haka or VIRTU. For users from non-Finnish institutions we will provide a separate username and password during the course (“Special Login”)
3) In the Notebooks dashboard click the “Join workspace” button in the upper left corner, and copy-paste there the join code `rsp-b7bij1x1`
4) You should now see "Spatial data analysis with R" RStudio Notebook appear in the list: start the application (opens in new tab).
5) Find the terminal tab, next to the console tab within RStudio.
6) Switch to `my-work` directory and copy the course materials there:
```
cd my-work
git clone https://github.com/csc-training/r-spatial-course.git
```
7) You can now find the course materials from the Files panel under `my-work/r-spatial-course`.
### Own course environment (optional!)
If you want to set up your own course environment on your own computer, you will need to install RStudio and all packages mentioned in https://github.com/csc-training/r-spatial-course/blob/main/install_packages.sh . For the STAC part, you in addition need `rstac`, `httr` and `gdalcubes`.
Then clone the course repository (`git clone git@github.com:csc-training/r-spatial-course.git`) and you are good to go :)
### Day 3. STAC
[Slides](https://a3s.fi/gis-courses/r_spatial/CSC_STAC_2023_05_12.pdf)
### Hands-on instructions:
1) Copy the example file to RStudio. Open Terminal and give these commands:
```
mkdir ~/my-work/stac
cd ~/my-work/stac
wget https://raw.githubusercontent.com/csc-training/geocomputing/master/R/STAC/STAC_CSC_example.R
```
2) Open the new RScript in RStudio from `stac` folder.
2) In R script change the path setting in row 45:
```
setwd('~/my-work/stac')
```
4) Run the script section-by-section.
4) Do not run rows 202-220, not enough memory in Notebooks.
## Questions and Answers
* is this how to ask questions?
* yes, and here is an answer!
* great!