Map biodiversity records with rgbif and dismo packages in R

July 15, 2012

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

In the earlier post we generated maps from GBIF biodiversity records using maps and ggplot2 packages. We used world map with country borders for that. Now we will generate maps with google maps as base layer using dismo package.

Like earlier we download data for Danaus chrysippus from GBIF using occurrencelist function into a data frame Dan_chr.

Then use dismo package which has function gmap to quickly download base layer maps form google and display it using plot function. We can specify the extent of map range we need to download using extent function and specifying Latitude and Longitude range. We plot the points first by converting them into Mercator system using points.

Dan_chr=occurrencelist(sciname = 'Danaus chrysippus',
                       coordinatestatus = TRUE,
                       maxresults = 1000,
                       latlongdf = TRUE, removeZeros = TRUE)
e = extent( -179 , 179 , -80 , 80 )
r = gmap(e)
plot(r, interpolate=TRUE, main="Map")
points(Mercator(xy1) , col='blue', pch=20)
text(160,0, "\n\n\nDanaus \nchrysippus", adj = c(0,1),

The output of the code snippet is as follows:

Map of Danaus chrysippus

To leave a comment for the author, please follow the link and comment on their blog: Vijay Barve. 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...

Comments are closed.

Search R-bloggers


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)