Interactive Graphs and Shiny Integration

STAT 220

Bastola

Spatial Data Analysis in R

sf (Simple Features)

  • Comprehensive Integration: Seamlessly handles spatial data within the tidyverse ecosystem, supporting complex spatial operations and integration with ggplot2 for advanced visualizations.

tigris

  • U.S. Geographic Detail: Directly accesses detailed U.S. Census Bureau shapefiles as sf objects, ideal for socio-economic and demographic studies.

rnaturalearth

  • Global Data Accessibility: Provides extensive global vector data from Natural Earth, ready for use with mapping tools like leaflet and ggplot2 for both interactive and static map creation.

library(sf)
library(tigris)
library(ggplot2)

ggplot(states()) +
  geom_sf(aes(fill = ALAND)) +
  coord_sf(xlim = c(-125, -66), ylim = c(25, 49), expand = FALSE) +
  labs(title = "US States by Land Area", fill = "Land Area") 

library(rnaturalearth)
library(sf)
library(ggplot2)
china_provinces <- ne_states(country = "China", returnclass = "sf")
ggplot(china_provinces) +
  geom_sf(fill = "lightblue", color = "black") +
  coord_sf(expand = FALSE) +
  labs(title = "Provinces of China")