Point patterns, where the only data are the locations of a set of point objects
# Warning: Some wild code happening here!
suppressPackageStartupMessages(require(dplyr))
suppressPackageStartupMessages(require(rvest))
suppressPackageStartupMessages(require(sf))
suppressPackageStartupMessages(require(tmap))
tmap_mode('view')
url <- "https://en.wikipedia.org/wiki/List_of_hydroelectric_power_stations_in_the_United_States"
dams <- url %>% read_html() %>%
html_node(xpath = '//*[@id="mw-content-text"]/div[1]/table[1]') %>%
html_table(trim = T) %>%
mutate(
y = Coordinates %>%
strsplit(" / |\\(") %>%
sapply('[',3) %>%
strsplit(";") %>%
sapply('[',1) %>%
trimws() %>% gsub("[^[:alnum:] \\.-]","",.) %>% as.numeric(),
x = Coordinates %>%
strsplit(" / |\\(") %>%
sapply('[',3) %>%
strsplit(";") %>%
lapply('[',2) %>%
unlist %>%
trimws() %>% gsub("[^[:alnum:] \\.-]","",.) %>% as.numeric(),
sus_output = `Capacity(MW)` %>% gsub(",","",.) %>% as.numeric
) %>%
dplyr::arrange(-sus_output) %>%
filter(!is.na(x),!is.na(y)) %>%
filter(!is.na(sus_output)) %>%
st_as_sf(coords = c("x","y"))
x <- tmap_leaflet(tm_shape(dams) +
tm_dots(col = 'blue'))
htmlwidgets::saveWidget(x,"~/documents/teaching/geog597/maps/6_dams_plain.html",selfcontained = T)Locations of major hydroelectric dams in the U.S.
x <- tmap_leaflet(
tm_shape(dams) + tm_dots(size = "sus_output", col = 'sus_output', palette = "GnBu",title = "Sustained Output (MW)",popup.vars=c("Sustained Output (MW)" = "sus_output"))
)
htmlwidgets::saveWidget(x,"~/documents/teaching/geog597/maps/6_dams_symbol.html",selfcontained = T)The spatial pattern of the distribution of a set of point features
The only valid measures of distributions are:


Each event has two coordinates
$$S = (S_{ix}, S_{iy})$$
The study region is represented by A, and it has area a

http://maptd.com/2010-united-states-mean-centre-of-population/






Any point is likely to occur at any location, and the position of any point is not affected by the position of any other point.
There is no apparent ordering of the distribution
Every point is as far from all of its neighbors as possible
Many points are concentrated close together, and there are large areas that contain few (if any) points





So what do we do?

Similar to quadrat counting approches:


Typical output surface from KDE, and its original point pattern
st_kde <- function(points,cellsize, bandwith, extent = NULL){
require(MASS)
require(raster)
require(sf)
if(is.null(extent)){extent_vec <- st_bbox(points)[c(1,3,2,4)]} else{extent_vec <-st_bbox(extent)[c(1,3,2,4)]}
n_y <- ceiling((extent_vec[4]-extent_vec[3])/cellsize)
n_x <- ceiling((extent_vec[2]-extent_vec[1])/cellsize)
extent_vec[2] <- extent_vec[1]+(n_x*cellsize)-cellsize
extent_vec[4] <- extent_vec[3]+(n_y*cellsize)-cellsize
coords <- st_coordinates(points)
matrix <- kde2d(coords[,1],coords[,2],h = bandwith,n = c(n_x,n_y),lims = extent_vec)
raster(matrix)
}
dam_kde <- st_kde(dams %>% filter(State %in% c("Oregon","Washington")),0.1,1)
x <- tmap_leaflet(tm_shape(dam_kde) +
tm_raster(title='KDE Estimation',palette = 'Blues', alpha = 0.65) +
tm_shape(dams %>% filter(State %in% c("Oregon","Washington"))) +
tm_dots(col='red'))
htmlwidgets::saveWidget(x,"~/documents/teaching/geog597/maps/6_dams_kde.html",selfcontained = T)Our dams as KDE!