Using R to Visualize Spatial Data:
R as a GIS
GIS
WHAT IS A GEOGRAPHIC INFORMATION
SYSTEM?
• Geographic – relates to a specific place on or in
relation to the Earth’s surface
• Information – is data to which some value or
interpretation has been added. In GI, the
information relates to measurements, maps,
images, sounds etc. of the Earth’s surface
• System – a system designed to perform a wide
range of functions on and with GI
• Although GISystems have developed greatly over
the past fifty years, their underlying principles 2
have remained the same
HOW DO WE VISUALISE
SPATIAL DATA?
• Layers in a GIS
To
p
Bottom
3
HOW DO WE VISUALISE
SPATIAL DATA?
• Layers
To
p
Bottom
4
HOW DO WE VISUALISE
SPATIAL DATA?
• E.g.
To
p
Bottom
5
MAPS ARE MODELS OF
REALITY
• Models are
generalisations of reality
• Visualisations will
determine what
is represented
• It is therefore
easy to
misrepresent
6
Monmonier (1996) How to lie with maps
POPULAR OPEN
SOFTWARE
• For analysing data
– R - [Link] and RStudio - [Link]
– Python [Link] and Jupyter - [Link]
• Databases
– PostgreSQL - [Link] & PostGIS
- [Link]
• Geographic information systems
– QGIS - [Link]
7
QGIS
• A fully functional open
source GIS
• Fantastical visualization
capacities
• An excellent alternative
to
ArcMap
R AND RSTUDIO
Advantages
• It is fast
• It is open source
• It is a well developed, simple and effective
programming language
• Lots of people use it- New York Times, Google,
Facebook, Ebay, University Researchers, etc….
• It can do anything you want it to (almost)
• It interfaces to other software very easily
• Can also call functions from other programming
languages (including SQL, Python, Java and
many more)
• It now has a large user community with lots of
and documentation
support 9
[Link]
[Link]
R AND RSTUDIO
• A large and comprehensive set of
packages (> 8600)
• Data access
• Data cleaning
• Analysis
• Visualization and report generation
• Excellent development environments
– RStudio IDE
• An active and friendly developers
community 10
[Link]
• A huge users community: > 2 million
[Link]
FEATURES OF R
• Command line interface.
• Object oriented.
– You create things with names • Can also be run through
using the “<-” symbol. Rstudio which provides
• Ten <- 5*2 a more user friendly
• Two <- Ten/5 GUI
• Write a script of functions.
Workspace
• The standard installation R Scripts
has
relatively few functions but more
have been made available via
open source downloadable
packages 11
Multi-tab
Console (includes plots)
FEATURES OF R
• 160+ packages in CRAN Task View:
Analysis of Spatial Data
• Classes for spatial (and spatio-temporal)
data
• Spatial data import/export
• Exploratory spatial data analysis
• Support for vector and raster operations
• Spatial statistics
• Data visualization through static and
dynamic (web) graphics
12
• Integration with GIS software
• Easy integration with techniques from non-
What is R?
• “R is a free software environment for statistical
computing and graphics. It compiles and runs on
a wide variety of UNIX platforms, Windows and
MacOS” ([Link]
• Available from The Comprehensive R Archive
Network: [Link]
13
• There are lots of options to improve
VISUALISATIONS the visualisation of data on a plot,
IN R such as proportional symbols,
colouring, 3D plotting, trend lines.
Average House Price
Size = Population (2011
Census)
% change in the
last 12 months
-
14
VISUALISATIONS IN R
15
Why use R?
• Because it is free and openly available across
platforms
• It is widely used with a large user-community
‐
• The help documentation is generally
excellent
• Moreover….
16
WHY USE R?
• It does what you want it to do (because it is a
programming language)
• It allows for reproducibility of results and for
collaborative working – essential for science and
social science. For example:
• Can place your data on a website; record your stages
of working as a script file; allow other people to run
the script, check for errors, make suggestions, etc.
17
WHY USE R FOR MAPPING / GIS /
SPATIAL ANALYSIS?
• R has strong visualization capabilities
• And strong statistical capabilities
• Not many software bring the two together whilst
also adding spatial data handling and spatial
analytical capabilities
• Even most GIS do not offer this; nor do most
statistical packages (which are not spatial)
18
WHY USE R FOR MAPPING / GIS /
SPATIAL ANALYSIS?
• A large and growing number of libraries for
handling spatial data in R have been developed
(and are freely available on CRAN)
• See especially :
•
[Link]
atial-data-analysis-and-visualisation-r
• [Link]
• [Link]
19
atial-data-analysis-and-visualisation-r