Skip to contents

eqr provides a thin R wrapper around the USGS FDSN earthquake web service. Results are returned as sf objects, so they slot directly into spatial workflows.

Installation

# install.packages("pak")
pak::pak("gitlab::mhaffner/eqr")

Basic usage

The main function is get_quakes(). At minimum you supply a time window:

library(eqr)
library(dplyr)

quakes <- get_quakes(
  start_time = "2026-03-16",
  end_time   = "2026-04-15"
)

quakes
#> Simple feature collection with 2262 features and 27 fields
#> Geometry type: POINT
#> Dimension:     XYZ
#> Bounding box:  xmin: -179.9647 ymin: -64.4186 xmax: 179.9615 ymax: 69.59
#> z_range:       zmin: -3.4 zmax: 694.69
#> Geodetic CRS:  WGS 84
#> First 10 features:
#>    tsunami    status       type alert felt
#> 1        0  reviewed earthquake  <NA>   NA
#> 2        0 automatic earthquake  <NA>    4
#> 3        0  reviewed earthquake  <NA>   NA
#> 4        0  reviewed earthquake  <NA>    1
#> 5        0  reviewed earthquake  <NA>   NA
#> 6        0  reviewed earthquake  <NA>    3
#> 7        0  reviewed earthquake  <NA>    1
#> 8        0  reviewed earthquake  <NA>   NA
#> 9        0  reviewed earthquake  <NA>   NA
#> 10       0  reviewed earthquake  <NA>   NA
#>                                                                                   detail
#> 1  https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=aka2026hivivj&format=geojson
#> 2     https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=nn00914628&format=geojson
#> 3  https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=aka2026hiujxi&format=geojson
#> 4     https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=nn00914624&format=geojson
#> 5     https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=us6000sq30&format=geojson
#> 6     https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=nn00914605&format=geojson
#> 7  https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=aka2026hiqnok&format=geojson
#> 8     https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=us6000sq2b&format=geojson
#> 9  https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=aka2026hiofjb&format=geojson
#> 10    https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=nn00914590&format=geojson
#>                                                                url   mmi
#> 1  https://earthquake.usgs.gov/earthquakes/eventpage/aka2026hivivj    NA
#> 2     https://earthquake.usgs.gov/earthquakes/eventpage/nn00914628    NA
#> 3  https://earthquake.usgs.gov/earthquakes/eventpage/aka2026hiujxi 2.043
#> 4     https://earthquake.usgs.gov/earthquakes/eventpage/nn00914624    NA
#> 5     https://earthquake.usgs.gov/earthquakes/eventpage/us6000sq30    NA
#> 6     https://earthquake.usgs.gov/earthquakes/eventpage/nn00914605    NA
#> 7  https://earthquake.usgs.gov/earthquakes/eventpage/aka2026hiqnok    NA
#> 8     https://earthquake.usgs.gov/earthquakes/eventpage/us6000sq2b    NA
#> 9  https://earthquake.usgs.gov/earthquakes/eventpage/aka2026hiofjb    NA
#> 10    https://earthquake.usgs.gov/earthquakes/eventpage/nn00914590    NA
#>                           ids cdi   tz      updated gap         time magType
#> 1  ,us6000sq3s,aka2026hivivj,  NA <NA> 1.776671e+12  69 1.776207e+12      ml
#> 2                ,nn00914628, 1.0 <NA> 1.776287e+12 290 1.776206e+12      ml
#> 3  ,us6000sq3l,aka2026hiujxi,  NA <NA> 1.776594e+12  57 1.776206e+12      ml
#> 4     ,nn00914624,us6000sq3h, 2.0 <NA> 1.776210e+12 121 1.776205e+12      ml
#> 5                ,us6000sq30,  NA <NA> 1.776204e+12 146 1.776201e+12      mb
#> 6     ,us6000sq2q,nn00914605, 2.2 <NA> 1.776249e+12 123 1.776200e+12      ml
#> 7  ,aka2026hiqnok,us6000sq2m, 1.0 <NA> 1.776589e+12  97 1.776199e+12      ml
#> 8                ,us6000sq2b,  NA <NA> 1.776199e+12 113 1.776197e+12      mb
#> 9  ,us6000sq1w,aka2026hiofjb,  NA <NA> 1.776589e+12  39 1.776194e+12      ml
#> 10    ,nn00914590,us6000sq1t,  NA <NA> 1.776237e+12 236 1.776194e+12      ml
#>                                        place  mag sources sig  dmin net
#> 1             49 km ESE of Pedro Bay, Alaska 2.60 ,us,ak, 104 0.000  ak
#> 2             4 km ESE of Enterprise, Nevada 2.50    ,nn,  97 0.494  nn
#> 3               72 km SE of Kokhanok, Alaska 3.80 ,us,ak, 222 0.200  ak
#> 4         17 km SE of Silver Springs, Nevada 2.71 ,nn,us, 113 0.361  nn
#> 5                  19 km SE of Tawang, India 4.00    ,us, 246 6.741  us
#> 6         16 km SE of Silver Springs, Nevada 3.14 ,us,nn, 152 0.362  nn
#> 7         32 km SW of Cooper Landing, Alaska 2.70 ,ak,us, 112 0.400  ak
#> 8             40 km SE of Londres, Argentina 4.40    ,us, 298 3.169  us
#> 9  49 km ENE of Denali National Park, Alaska 2.70 ,us,ak, 112 0.600  ak
#> 10        19 km SE of Silver Springs, Nevada 3.27 ,nn,us, 165 0.341  nn
#>           code                        types    rms nst
#> 1  a2026hivivj          ,origin,phase-data, 0.7000 103
#> 2     00914628     ,dyfi,origin,phase-data, 0.4138  20
#> 3  a2026hiujxi ,origin,phase-data,shakemap, 0.9000 184
#> 4     00914624     ,dyfi,origin,phase-data, 0.1302  27
#> 5     6000sq30          ,origin,phase-data, 0.8900  30
#> 6     00914605     ,dyfi,origin,phase-data, 0.1583  22
#> 7  a2026hiqnok     ,dyfi,origin,phase-data, 0.8000  74
#> 8     6000sq2b          ,origin,phase-data, 0.6900  32
#> 9  a2026hiofjb          ,origin,phase-data, 1.0000  80
#> 10    00914590          ,origin,phase-data, 0.1706  17
#>                                                title
#> 1             M 2.6 - 49 km ESE of Pedro Bay, Alaska
#> 2             M 2.5 - 4 km ESE of Enterprise, Nevada
#> 3               M 3.8 - 72 km SE of Kokhanok, Alaska
#> 4         M 2.7 - 17 km SE of Silver Springs, Nevada
#> 5                  M 4.0 - 19 km SE of Tawang, India
#> 6         M 3.1 - 16 km SE of Silver Springs, Nevada
#> 7         M 2.7 - 32 km SW of Cooper Landing, Alaska
#> 8             M 4.4 - 40 km SE of Londres, Argentina
#> 9  M 2.7 - 49 km ENE of Denali National Park, Alaska
#> 10        M 3.3 - 19 km SE of Silver Springs, Nevada
#>                          geometry    depth
#> 1  POINT Z (-153.258 59.682 12... 124.3000
#> 2  POINT Z (-115.1958 36.0114 ...   0.0390
#> 3  POINT Z (-153.995 58.927 12... 121.7000
#> 4  POINT Z (-119.0699 39.3203 ...   7.5467
#> 5    POINT Z (92.0607 27.4515 10)  10.0000
#> 6  POINT Z (-119.0693 39.3218 ...  10.9495
#> 7  POINT Z (-150.179 60.255 28.4)  28.4000
#> 8  POINT Z (-66.8501 -27.9783 ... 225.8840
#> 9    POINT Z (-150.743 63.64 3.3)   3.3000
#> 10 POINT Z (-119.0554 39.2948 ...   8.9304

By default this returns M2.5+ events globally. The result is an sf data frame — each row is one earthquake, with a geometry column (point) and columns sourced directly from the USGS GeoJSON properties.

Commonly useful columns:

Column Description
mag Magnitude
place Human-readable location description
time Origin time (milliseconds since epoch)
depth Depth in km
magType Magnitude scale (ml, mw, mb, …)
type Event type (usually "earthquake")
url USGS event page
status "reviewed" or "automatic"

Filtering by magnitude

# Only significant events
major <- get_quakes(
  start_time = "2026-01-01",
  end_time   = "2026-04-15",
  min_mag    = 5.0
)

nrow(major)
#> [1] 542
range(major$mag)
#> [1] 5.0 7.5

Filtering by region

Pass latitude/longitude bounds to restrict the spatial extent:

# Pacific Northwest
pnw <- get_quakes(
  start_time = "2026-01-01",
  end_time   = "2026-04-15",
  min_mag    = 2.5,
  min_lat    = 42,  max_lat = 49,
  min_lng    = -124, max_lng = -116
)

Checking the event count first

The USGS caps responses at 20,000 events per request — with no error, just silent truncation. For any query covering a long time window or low magnitude threshold, check the count before pulling data:

n <- count_quakes(
  start_time = "2025-01-01",
  end_time   = "2026-04-15",
  min_mag    = 2.5
)

n  # if this is > 20000, use auto_chunk = TRUE (see below)
#> [1] 36731

Handling large queries with auto_chunk

When a query would exceed 20,000 events, set auto_chunk = TRUE. get_quakes() will call count_quakes() internally, then split the time window into chunk_days-day segments and combine the results:

quakes <- get_quakes(
  start_time = "2025-01-01",
  end_time   = "2026-04-15",
  min_mag    = 2.5,
  auto_chunk = TRUE,
  chunk_days = 30    # query one month at a time
)

nrow(quakes)
#> [1] 36731

Sorting results

The order_by argument controls sort order. Options are "time" (default, most recent first), "time-asc", "magnitude", and "magnitude-asc":

# Largest events first
top_quakes <- get_quakes(
  start_time = "2026-01-01",
  end_time   = "2026-04-15",
  min_mag    = 2.5,
  order_by   = "magnitude"
)

top_quakes |>
  select(mag, place, time) |>
  slice_head(n = 10)
#> Simple feature collection with 10 features and 3 fields
#> Geometry type: POINT
#> Dimension:     XYZ
#> Bounding box:  xmin: -175.3917 ymin: -61.1875 xmax: 176.3707 ymax: 52.3258
#> z_range:       zmin: 10 zmax: 629
#> Geodetic CRS:  WGS 84
#>    mag                               place         time
#> 1  7.5           148 km W of Neiafu, Tonga 1.774327e+12
#> 2  7.4    126 km WNW of Ternate, Indonesia 1.775084e+12
#> 3  7.3    48 km ENE of Luganville, Vanuatu 1.774860e+12
#> 4  7.0   56 km NNW of Kota Belud, Malaysia 1.771779e+12
#> 5  6.6         northern Mid-Atlantic Ridge 1.774095e+12
#> 6  6.5              South Shetland Islands 1.773966e+12
#> 7  6.5        0 km W of San Marcos, Mexico 1.767362e+12
#> 8  6.5           123 km E of Yamada, Japan 1.774535e+12
#> 9  6.4  223 km ESE of Attu Station, Alaska 1.772647e+12
#> 10 6.4 247 km SE of Sarangani, Philippines 1.768057e+12
#>                          geometry
#> 1  POINT Z (-175.3917 -18.597 ...
#> 2    POINT Z (126.2965 1.1171 35)
#> 3  POINT Z (167.5616 -15.3139 ...
#> 4   POINT Z (116.2475 6.8241 629)
#> 5   POINT Z (-45.7987 23.8601 10)
#> 6  POINT Z (-56.4033 -61.1875 21)
#> 7    POINT Z (-99.3939 16.798 18)
#> 8   POINT Z (143.3826 39.4377 16)
#> 9   POINT Z (176.3707 52.3258 10)
#> 10   POINT Z (126.9922 3.7767 31)

Working with sf output

Because the output is an sf object, standard spatial operations work immediately:

library(sf)

# Check the CRS (always WGS 84 from USGS)
st_crs(quakes)
#> Coordinate Reference System:
#>   User input: 4326 
#>   wkt:
#> GEOGCS["WGS 84",
#>       DATUM["WGS_1984",
#>         SPHEROID["WGS 84",6378137,298.257223563,
#>           AUTHORITY["EPSG","7030"]],
#>         AUTHORITY["EPSG","6326"]],
#>       PRIMEM["Greenwich",0,
#>         AUTHORITY["EPSG","8901"]],
#>       UNIT["degree",0.0174532925199433,
#>         AUTHORITY["EPSG","9122"]],
#>       AXIS["Latitude",NORTH],
#>       AXIS["Longitude",EAST],
#>     AUTHORITY["EPSG","4326"]]

# Bounding box of results
st_bbox(quakes)
#>      xmin      ymin      xmax      ymax 
#> -179.9997  -84.4932  179.9994   87.0815

# Filter to events shallower than 20 km
shallow <- quakes |> filter(depth < 20)

shallow |> head()
#> Simple feature collection with 6 features and 27 fields
#> Geometry type: POINT
#> Dimension:     XYZ
#> Bounding box:  xmin: -105.3691 ymin: 9.8536 xmax: 120.4498 ymax: 43.6341
#> z_range:       zmin: 0 zmax: 17.31
#> Geodetic CRS:  WGS 84
#>   tsunami   status             type alert felt
#> 1       0 reviewed       earthquake  <NA>   NA
#> 2       0 reviewed       earthquake  <NA>   NA
#> 3       0 reviewed       earthquake  <NA>   NA
#> 4       0 reviewed mining explosion  <NA>   NA
#> 5       0 reviewed       earthquake  <NA>   NA
#> 6       0 reviewed       earthquake  <NA>   14
#>                                                                               detail
#> 1 https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=us7000pa8c&format=geojson
#> 2 https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=us7000pa6n&format=geojson
#> 3 https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=tx2025ccsy&format=geojson
#> 4 https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=us7000pa5u&format=geojson
#> 5 https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=us7000pa5h&format=geojson
#> 6 https://earthquake.usgs.gov/fdsnws/event/1/query?eventid=us7000pa3c&format=geojson
#>                                                            url mmi
#> 1 https://earthquake.usgs.gov/earthquakes/eventpage/us7000pa8c  NA
#> 2 https://earthquake.usgs.gov/earthquakes/eventpage/us7000pa6n  NA
#> 3 https://earthquake.usgs.gov/earthquakes/eventpage/tx2025ccsy  NA
#> 4 https://earthquake.usgs.gov/earthquakes/eventpage/us7000pa5u  NA
#> 5 https://earthquake.usgs.gov/earthquakes/eventpage/us7000pa5h  NA
#> 6 https://earthquake.usgs.gov/earthquakes/eventpage/us7000pa3c  NA
#>                       ids cdi   tz      updated gap         time magType
#> 1            ,us7000pa8c,  NA <NA> 1.744751e+12 211 1.738279e+12      mb
#> 2            ,us7000pa6n,  NA <NA> 1.744751e+12 101 1.738279e+12      mb
#> 3 ,us7000pah1,tx2025ccsy,  NA <NA> 1.744751e+12  63 1.738278e+12      ml
#> 4            ,us7000pa5u,  NA <NA> 1.744751e+12  73 1.738271e+12      ml
#> 5            ,us7000pa5h,  NA <NA> 1.744751e+12  88 1.738268e+12     mwr
#> 6            ,us7000pa3c, 3.4 <NA> 1.744751e+12  47 1.738253e+12     mwr
#>                         place mag sources sig  dmin net     code
#> 1  northern East Pacific Rise 4.6    ,us, 326 9.510  us 7000pa8c
#> 2   28 km SSE of Gerāsh, Iran 4.0    ,us, 246 3.035  us 7000pa6n
#> 3 15 km ESE of Lindsay, Texas 2.6 ,us,tx, 104 0.000  tx 2025ccsy
#> 4 16 km SE of Wright, Wyoming 2.9    ,us, 129 1.080  us 7000pa5u
#> 5  4 km NNW of Yujing, Taiwan 4.0    ,us, 246 0.212  us 7000pa5h
#> 6 1 km ESE of Alivéri, Greece 4.1    ,us, 263 2.077  us 7000pa3c
#>                                    types  rms nst
#> 1                    ,origin,phase-data, 0.92  40
#> 2                    ,origin,phase-data, 1.08  50
#> 3                    ,origin,phase-data, 0.20  14
#> 4                    ,origin,phase-data, 0.23  20
#> 5      ,moment-tensor,origin,phase-data, 0.41  35
#> 6 ,dyfi,moment-tensor,origin,phase-data, 1.07  51
#>                                                  title   depth
#> 1                   M 4.6 - northern East Pacific Rise 10.0000
#> 2                    M 4.0 - 28 km SSE of Gerāsh, Iran 10.0000
#> 3                  M 2.6 - 15 km ESE of Lindsay, Texas  3.1262
#> 4 M 2.9 Mining Explosion - 16 km SE of Wright, Wyoming  0.0000
#> 5                   M 4.0 - 4 km NNW of Yujing, Taiwan 11.4190
#> 6                  M 4.1 - 1 km ESE of Alivéri, Greece 17.3100
#>                         geometry
#> 1  POINT Z (-104.3665 9.8536 10)
#> 2   POINT Z (54.2511 27.4325 10)
#> 3 POINT Z (-103.396 31.292 3....
#> 4  POINT Z (-105.3691 43.6341 0)
#> 5 POINT Z (120.4498 23.1678 1...
#> 6 POINT Z (24.0458 38.4121 17...