# Map biodiversity records with rgbif and dismo packages in R

July 15, 2012
By

(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.

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

The output of the code snippet is as follows: