Code
source("../dsan-globals/_globals.r")
source("../dsan-globals/_globals-sf.r")
library(rnaturalearth)
library(mapview)PPOL 6805 / DSAN 6750: GIS for Spatial Data Science
Fall 2026
source("../dsan-globals/_globals.r")
source("../dsan-globals/_globals-sf.r")
library(rnaturalearth)
library(mapview)Using rnaturalearth with mapview
set.seed(6805)
library(tidyverse)── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.2.1 ✔ readr 2.2.0
✔ forcats 1.0.1 ✔ stringr 1.6.0
✔ lubridate 1.9.5 ✔ tibble 3.3.1
✔ purrr 1.2.1 ✔ tidyr 1.3.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(sf)Linking to GEOS 3.13.0, GDAL 3.8.5, PROJ 9.5.1; sf_use_s2() is TRUE
library(rnaturalearth)
library(mapview)
france_sf <- ne_countries(country = "France", scale = 50)
(france_map <- mapview(france_sf, label = "geounit", legend = FALSE))france_cent_sf <- sf::st_centroid(france_sf)Warning: st_centroid assumes attributes are constant over geometries
france_map + mapview(france_cent_sf, label = "Centroid", legend = FALSE)Computing the union of all geometries in the sf via sf::st_union()
library(leaflet.extras2)Loading required package: leaflet
africa_sf <- ne_countries(continent = "Africa", scale = 50)
africa_union_sf <- sf::st_union(africa_sf)
africa_map <- mapview(africa_sf, label="geounit", legend=FALSE)
africa_union_map <- mapview(africa_union_sf, label="st_union(africa)", legend=FALSE)
africa_map | africa_union_mapafrica_bbox_sf <- sf::st_bbox(africa_sf)
africa_bbox_map <- mapview(africa_bbox_sf, label="st_bbox(africa)", legend=FALSE)
africa_map | africa_bbox_mapafrica_countries_cvx <- sf::st_convex_hull(africa_sf)
africa_countries_cvx_map <- mapview(africa_countries_cvx, label="geounit", legend=FALSE)
africa_map | africa_countries_cvx_mapUse st_union() first:
africa_cvx <- africa_sf |> st_union() |> st_convex_hull()
africa_cvx_map <- mapview(africa_cvx, label="geounit", legend=FALSE)
africa_map | africa_cvx_mapComputing the centroid of all geometries in the sf via sf::st_centroid()
africa_cents_sf <- sf::st_centroid(africa_sf)Warning: st_centroid assumes attributes are constant over geometries
africa_cents_map <- mapview(africa_cents_sf, label="geounit", legend=FALSE)
africa_map | africa_cents_mapThe Earth’s “width” is slightly greater than its “length” 😰







Is poverty a “significant issue” in the US?
Is poverty a “significant issue” in the US?
Assigns the same number of observations to each color
Is poverty a “significant issue” in the US?
Boundaries between colors come at regular (equal) intervals
Is poverty a “significant issue” in the US?
Clustering algorithm chooses classes to (a) minimize differences within classes, (b) maximize differences between classes
Is poverty a “significant issue” in the US?
A government program offers special funding for counties with above 25% poverty
Is poverty a “significant issue” in the US?