Introduction To GIS With R
Introduction To GIS With R
Files/Plots/Packages
Console: Where /Help/Viewer
R code is
executed
RStudio
Click on File>New File>R Script script to
open a new R script
Importance of scripting:
– Allows others to reproduce your work
– Serves as instruction/reminder on how to perform a
task
Basics of R scripting
To write script, open a new R script file by clicking
File>New>File>R Script.
Within the text editor, you can type out a sequence of functions
A command can be executed from the text editor by placing the cursor
on a line and pressing Ctrl+Enter, or clicking the Run button.
Vector arithmetic:
Reading data into R
Large data objects will usually be read as values from external files
rather than entered during
an R session at the keyboard
There are a number of functions which are used to read data into R
depending on the type of the data file
Examples:
– To read csv data into R, the read.csv() function is used
– To read shapefiles into R, the st_read() function is used
– To read a single raster file, the raster() function is used
Reading data into R
Read gps_points csv file located in the
working directory:
Result:
Reading data into R
You can use
the File>Import
Dataset tab to
import text,
excel, spss, sas
or stata
GIS with R: