PPOL 6805 / DSAN 6750: GIS for Spatial Data Science
Fall 2025
Wednesday, September 25, 2024
library(rnaturalearth)
library(tidyverse)
library(sf)
library(mapview)
library(leaflet.extras2)
africa_sf <- ne_countries(continent = "Africa", scale = 50) |> select(iso_a3, geounit)
africa_map <- mapview(africa_sf, label="geounit", legend=FALSE)
N <- 10
africa_union_sf <- sf::st_union(africa_sf)
sampled_points_sf <- sf::st_sample(africa_union_sf, N) |> sf::st_sf() |> mutate(temp = runif(N, 0, 100))
sampled_points_map <- mapview(sampled_points_sf, label="Random Point", col.regions=cbPalette[1], legend=FALSE)
countries_points_sf <- africa_sf[sampled_points_sf,]
filtered_map <- mapview(countries_points_sf, label="geounit", legend=FALSE) + sampled_points_map
(africa_map + sampled_points_map) | filtered_map
POINT
s are not merged into data attributes of POLYGON
sPOINT
Attributes
geom | temp |
---|---|
POINT (25.01188 17.48124) | 94.077452 |
POINT (-11.51267 8.601504) | 63.883835 |
POINT (45.69584 7.05268) | 42.239019 |
POINT (16.2126 -18.06288) | 14.691093 |
POINT (2.687359 17.20779) | 62.262726 |
POINT (9.959565 7.661023) | 1.091668 |
st_join()
iso_a3 | geounit | temp | geometry | |
---|---|---|---|---|
53 | SDN | Sudan | 94.077452 | MULTIPOLYGON (((34.07812 9…. |
64 | SLE | Sierra Leone | 63.883835 | MULTIPOLYGON (((-10.2832 8…. |
91 | NGA | Nigeria | 1.091668 | MULTIPOLYGON (((7.300781 4…. |
102 | NAM | Namibia | 14.691093 | MULTIPOLYGON (((23.38066 -1… |
114 | MLI | Mali | 62.262726 | MULTIPOLYGON (((-11.3894 12… |
123 | LBY | Libya | 45.156028 | MULTIPOLYGON (((9.51875 30…. |
Assume the extensive attribute \(Y\) is uniformly distributed over a space \(S_i\) (e.g., for population counts we assume everyone is evenly-spaced across the region)
We first compute \(Y_{ij}\), derived from \(Y_i\) for a sub-area of \(S_i\), \(A_{ij} = S_i \cap T_j\):
\[ \hat{Y}_{ij}(A_{ij}) = \frac{|A_{ij}|}{|S_i|}Y_i(S_i) \]
where \(|\cdot|\) denotes area.
Then we can compute \(Y_j(T_j)\) by summing all the elements over area \(T_j\):
\[ \hat{Y}_j(T_j) = \sum_{i=1}^{p}\frac{|A_{ij}|}{|S_i|}Y_i(S_i) \]
\[ \hat{Y}_{ij} = Y_i(S_i) \]
\[ \hat{Y}_j(T_j) = \sum_{i=1}^{p}\frac{|A_{ij}|}{|T_j|}Y_j(S_i) \]
Introducing the spdep
library!
PPOL 6805 Week 5: Spatial Data Science