Week15Live3

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 19

What R you

excited to do
with R?
Enter your response NOW:
ttpoll.eu SessionID: pirate
Review

Sources for spatial data


Week 15 live:
spatial data
Group activity

Point pattern Analysis (Quadrat)


remotes::install_githu
Installing & loading b("ropensci/
rnaturalearthhires")
packages library("rnaturalearth
hires")

Data + aesthetics +

Review
geometries ...
Ggplot uses layers Plotting points: plot(x,
y, ...)
• plot(3,8)

Projections and coordinate


systems
Spatial packages in R

tmap maps rgeos sp sf GIStools GIStools

rgdal rgeos raster Spatstat Leaflet rgooglemaps Ggmap


Upload any shapefile to R

Upload a CSV to R

Sources for Use an API to import spatial OpenStreetMap, NOMIS, Census, etc...
data:
spatial data
Create spatial data from Geocoding
within R: From a data frame

Natural earth data


Use a package that has GADMTools
spatial data included Gapminder
osmdata
Geocoding

Transforms a text An address (123 Main


St, City, State, Post
string into X, Y Code)
A city, a state, etc..
coordinates (London)

Requires an a service (API) finds


matches between
'address locator' input and reference
data
(reference data) returns coordinates

Start with a list of


Generally done in a locations (e.g. survey
respondents)
batch process Ends with a map with
points
What is "sp"?
The structure for spatial objects used in also the name of the package
R are called "sp"

The 'sp' defines classes (sp objects) for handling points, lines and areas

In sp the "spatial" class of an object has A bounding box

two "slots" (slot = property) A CRS class object that defines the coordinate reference system

The data frame of sp objects can be object@slot

accessed using the @data parameter Ahouse@price


The structure depends on the characteristics of the spatial
the structure of 'sp' object
The spatial data frames work like any other data frame in R

Without attributes With attributes In ArcGIS/desktop


SpatialPoints SpatialPointsDataFrame Point shapefile

SpatialLines SpatialLinesDataFrame Line shapefile

SpatialPolygon SpatialPolygonDataFrame Polygon shapefile


Visit: http://tiny.cc/pirateroom
find the page for your room

•Create the code as a group


•Use RStudio on your own comptuers
•Paste each chunk of code into the
Google Doc
•Paste the final map into the google doc
for your page
•If you feel uncomfortable disclosing your
location, make one up.
My solution
http://tiny.cc/piratebr
Point Pattern Analysis:
study of spatial arrangement
of points in space
• Clustering: Are their "hotspots" for burglaries in this
city?
• Compare events: Do crime and poverty have the same
spatial distribution?
Why point pattern analysis?

To explore and visualise the data

To create and calibrate models of the process generating the data

detection and location of spatial clusters of events


To test hypotheses related to the
whether two kinds of event have the same spatial
processes generating the data distribution
Types of point pattern
analysis
Density based analysis- pattern based on distribution in
the study area
• Global density
• Local density
• Quadrat density
• Kernel density

Distance based analysis-measures how points are


distributed relative to one another (not study extent)
• Nearest neighbour
Quadrat Analysis

• Quadrats of cells (usually


squares) are superimposed on a
study area and the number of
points in each cell is calculated
• By analyzing the distribution of
cell frequences, the point pattern
arrangement can be described
(variability in number of points
per cell)
Interpreting the results:
If each of the quadrats (cells) contains the same number of points, the pattern would show no variabilities
in frequency and would be perfectly dispersed

• Random: any point is equally likely


to occur at any location (unaffected
by other points). Objects are neither
clustered nor dispersed. This is what
we also refer to as a or "normative"
pattern.
• dispersed or uniform: occurs when
every point is as far away from
another as possible (maximally
spread out)
• Clustered: occurs when objects exist
in close proximity to one another.
Quadrat Scale Problem

• the application of quadrat methods is


always affected by scale because
selection of the size of cell is arbitrary
Let's try this in R
Follow along: http://tiny.cc/w15pirate
The variance-means ratio (VMR) standardizes the
degree of variabilty in cell frequences in relation to
mean cell frequency

VMR is calculated by dividing the variance of the cell


frequences (VAR) by the mean

Describing
the results
The VMR produces a descriptive index

Can be applied inferentailly to


test a distribution for X2 =VMR(m-1)
randomness with a chi-
square:

You might also like