code/old-to-future-remove/10-earthquakes.R

# Aim: create up-to-date map of Earthquakes in previous week

# setup ------------------------------------------------------------------

library(sf)
library(spData)

# download data -----------------------------------------------------------

u = "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/significant_month.geojson"
earthquakes = read_sf(u)
# summary(earthquakes) # summarise

# text results ------------------------------------------------------------

print(paste0(nrow(earthquakes), " significant earthquakes happened last month"))

# map ---------------------------------------------------------------------

plot(st_geometry(world), border = "gray")
plot(st_geometry(earthquakes), cex = earthquakes$mag, add = TRUE)
title(paste0(
  "Location of significant (mag > 5) Earthquakes in the month to ",
  Sys.Date(),
  "\n(circle diameter is proportional to magnitude)"
))
Robinlovelace/geocompr documentation built on June 14, 2025, 1:21 p.m.