Latest Code for Chris and Lex's Book
1
Introduction
2
Data and Plots
2.1
Introduction
2.2
The basic ingredients of R: variables and assignment
2.3
Data types and Data classes
2.3.1
Data Types in R
2.3.2
Data Classes in R
2.3.3
Self-Test Questions
2.4
Plots
2.4.1
Basic Plot Tools
2.4.2
Plot colours
2.5
Another plot option:
ggplot
2.5.1
Introduction to
ggplot
2.5.2
Different
ggplot
types
2.6
Reading, writing, loading and saving data
2.6.1
Text files
2.6.2
R Data files
2.6.3
Spatial Data files
2.7
Answers to self-test questions
3
Basics of Handling Spatial Data in R
3.1
Overview
3.1.1
Spatial Data
3.1.2
Installing and loading packages
3.2
Introduction to
sp
and
sf
: the
sf
revolution
3.2.1
sp
data format
3.2.2
sf
data format
3.3
sp SpatialPolygonDataFrame object
3.4
sf polygon object
3.5
Reading and Writing Spatial Data
3.5.1
Reading to and writing from
sp
format
3.5.2
Reading to and writing from
sf
format
3.6
Mapping: an introduction to
tmap
3.6.1
Introduction
3.6.2
A quick
tmap
3.6.3
Full
tmap
3.6.4
Adding context
3.6.5
Saving your map
3.7
Mapping spatial data attributes
3.7.1
Introduction
3.7.2
Attributes and data frames
3.7.3
Mapping polygons and attributes
3.7.4
Mapping points and attributes
3.7.5
Mapping lines and attributes
3.7.6
Mapping raster attributes
3.8
Simple descriptive statistical analyses
3.8.1
Histograms and Boxplots
3.8.2
Scatterplots and Regressions
3.8.3
Mosaic Plots
3.9
Self-Test Questions
3.10
Answers to self-test questions
4
Scripting and Writing Functions in R
4.1
Overview
4.2
Introduction
4.3
Building blocks for Programs
4.3.1
Conditional Statements
4.3.2
Code Blocks:
\(\{\)
and
\(\}\)
4.3.3
Functions
4.3.4
Loops and repetition
4.3.5
Debugging
4.4
Writing Functions
4.4.1
Introduction
4.4.2
Data Checking
4.4.3
More Data Checking
4.4.4
Loops Revisited
4.4.5
Further Activity
4.5
Spatial data structures
4.6
Apply functions
4.7
the
(
???
)
route
4.8
the data frame route
4.9
Manipulating data with
dplyr
4.10
Answers to self-test questions
5
Using R as a GIS
5.1
Introduction
5.2
Spatial Intersection and Clip Operations
5.3
Buffers
5.4
Merging spatial features
5.4.1
with rgeos and sp - commented out
5.4.2
with sf and tmap
5.5
Point-in-polygon and Area calculations
5.5.1
Point-in-polygon
5.5.2
Area calculations
5.5.3
Point and Areas analysis exercise
5.6
Creating distance attributes
5.6.1
Distance analysis / Accessibility exercise
5.7
Combining spatial datasets and their attributes
5.8
define sample grid in polygons
5.9
in rgdal
5.10
in sf
5.11
Converting between Raster and Vector
5.11.1
Vector to Raster
5.11.2
Converting to
sp
raster classes
5.12
Introduction to Raster Analysis
5.12.1
Raster Data Preparation
5.12.2
Raster Reclassification
5.12.3
Other Raster Calculations
5.13
Answers to self-test questions
6
Point Pattern Analysis Using R
6.1
Introduction
6.2
What is special about spatial?
6.2.1
Point Patterns
6.3
Techniques for Point Patterns Using R
6.3.1
Kernel Density Estimates
6.3.2
Kernel Density Estimation Using R
6.3.3
Further Uses of Kernel Density Estimation
6.3.4
Hexagonal Binning Using R
6.3.5
Second Order Analysis of Point Patterns
6.4
Using The
\(K\)
-function in R
6.4.1
The
\(L\)
-function
6.5
The
\(G\)
-function
6.6
Looking at Marked Point Patterns
6.7
Cross-
\(L\)
-function analysis in R
6.8
Interpolation of Point Patterns With Continuous Attributes
6.8.1
Nearest Neighbour Interpolation
6.8.2
A Look at the Data
6.8.3
Inverse Distance Weighting (IDW)
6.8.4
Computing IDW with the
gstat
Package
6.9
The Kriging approach
6.9.1
A Brief Introduction to Kriging
6.9.2
Random Functions
6.9.3
Estimating the Semivariogram
6.10
Concluding Remarks
7
Spatial Attribute Analysis With R
7.1
Introduction
8
THE PENNSYLVANIA LUNG CANCER DATA
9
A VISUAL EXPLORATION OF AUTOCORRELATION
9.1
Neighbours and Lagged Mean Plots
10
MORAN’S I: AN INDEX OF AUTOCORRELATION
10.1
Moran’s-
\(I\)
in R
10.2
A Simulation-Based Approach
11
SPATIAL AUTOREGRESSION
12
CALIBRATING SPATIAL REGRESSION MODELS IN R
12.1
Models with predictors: A Bivariate Example
12.2
Further Issues
12.3
Troubleshooting Spatial Regression
13
REFERENCES
14
Localised Spatial Analysis
15
R and Internet Data
References
Published with bookdown
Code for
An Introduction to Spatial Analysis and Mapping in R
2nd edition
Chapter 13
REFERENCES