Global Volcanic Eruptions

[This article was first published on rare earth, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

What volcanoes are currently erupting across the globe, you ask?  Building on an earlier post of global earthquakes, we can scrape some weekly data from the Smithsonian/USGS Global Volcanism Program to plot the locations of actively erupting volcanoes with R.

The weekly data are provided as an RSS (.xml) feed with the location of each eruption tagged as:

latitude longitude


The below code extracts and parses the location string, converts the string to numeric values, and stores the location of each eruption in a data frame.  From there you can plot the data just as in the earthquakes post.  In fact, the figure below shows all of the active volcanic eruptions (orange circles) and recent earthquakes (blue circles, scaled by magnitude).

 
For more info on active volcanic eruptions visit the Smithsonian/USGS Global Volcanism Program or check out the excellent Eruptions blog, by Erik Klemetti.

Global Volcanic Eruptions Code:

# Get the current eruptions from Smithosonian/USGS
doc <- xmlInternalTreeParse("http://www.volcano.si.edu/news/WeeklyVolcanoRSS.xml")
 
# Parse xml and isolate the eruption locations
x <- xpathApply(doc, "//georss:point")
len <- length(x)
df <- xmlToDataFrame(x)
 
# Convert the eruption list to numeric lat lon
lat <- c()
lon <- c()
for (i in 1:len){
  char <- as.character(df[i, 1])
  num <- as.numeric(unlist(strsplit(char, " ")))
  lat[[i]] <- num[[1]]
  lon[[i]] <- num[[2]]
  }  
vlc <- data.frame(lat, lon)

Side Note:

The map produced above would probably be better if it were centered on the Pacific Ocean, rather than North America.  Using the mapproj package to rotate the image with the orient=c(lat, lon, deg) command, however, results in prominent streaking of country boundaries.  If anyone has a work around to this, I'd be grateful.

To leave a comment for the author, please follow the link and comment on their blog: rare earth.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)