Global Volcanic Eruptions

December 10, 2011

(This article was first published on rare earth, and kindly contributed to R-bloggers)

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("")
# 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. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: ,

Comments are closed.


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)