Skip to contents

Queries the USGS FDSN event web service and returns earthquake data as an sf object. By default the spatial extent is global and minimum magnitude is 2.5.

Usage

get_quakes(
  start_time,
  end_time = Sys.time(),
  min_mag = 2.5,
  min_lat = -90,
  max_lat = 90,
  min_lng = -180,
  max_lng = 180,
  order_by = "time",
  limit = NULL,
  auto_chunk = FALSE,
  chunk_days = 30
)

Arguments

start_time

POSIXct or character (e.g. "2026-03-01"). Start of the query window (UTC).

end_time

POSIXct or character. End of the query window (UTC). Defaults to now.

min_mag

Minimum magnitude. Default 2.5.

min_lat, max_lat

Latitude bounds. Default global (-90, 90).

min_lng, max_lng

Longitude bounds. Default global (-180, 180).

order_by

Sort order: "time" (default), "time-asc", "magnitude", or "magnitude-asc".

limit

Maximum events to return (max 20,000). NULL uses the USGS default.

auto_chunk

Logical. If TRUE and the event count exceeds limit (or 20,000 when limit = NULL), the time window is split into equal chunks and results are combined. Default FALSE.

chunk_days

Integer. Number of days per chunk when auto_chunk = TRUE. Default 30.

Value

An sf data frame. Each row is one earthquake event. Columns come directly from the USGS GeoJSON properties (e.g. mag, place, time, depth).

Details

The USGS caps responses at 20,000 events per request. For large queries use count_quakes() first, then chunk the time window manually or set auto_chunk = TRUE to let this function split the request automatically.

Examples

if (FALSE) { # \dontrun{
# Last 30 days, contiguous US, M2.5+
quakes <- get_quakes(
  start_time = Sys.time() - 30 * 86400,
  end_time   = Sys.time()
)

# Specify a region and magnitude cutoff
quakes <- get_quakes(
  start_time = "2026-01-01",
  end_time   = "2026-04-01",
  min_mag    = 4.0,
  min_lat    = 32, max_lat = 42,
  min_lng    = -125, max_lng = -114
)
} # }