Downloading volcano data from USGS with R

I noticed that USGS has published JSON data with the volcanoes of the world and that is simply too interesting to miss, so here is a very short R script to view the data on a map. This script will:

  • Download the JSON data
  • Convert to sf geometry
  • View the volcanoes on a map

#Load libraries
library(jsonlite)
library(mapview)
library(sf)

# Define URL
url <- "https://volcview.wr.usgs.gov/vv-api/volcanoApi/wwvolcanoes"

# JSON
json_data <- fromJSON(url)

# sf geometry, EPSG=4326
volcanoes <- st_as_sf(json_data, coords = c("lng", "lat"), crs = 4326)

# View result on map
mapview(volcanoes, col.regions = "RED")

A few images of the result:

1566 volcanoes

When the time came for mankind to pick locations for the volcanoes, Japan was not forgotten.

Galapagos proves that an island, without a volcano, is not an island.

If you want to create a web map, have a look at Creating an interactive web map using R/Leaflet. I you just want the map, it´s right here:

This is an excellent solution if you want to add a simple web map with the volcano data set to your site.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please reload

Please Wait