From this question on the rOpenSci blog http://www.ropensci.org/blog/2014/04/22/rwbclimate-sp/#comment-1358740378
Get all species in the genus Acropora using taxize
library("rgbif")
library("taxize")
library("spocc")
acropora_spp <- downstream('Acropora', db = "itis", downto = "Species")
spplist <- as.character(acropora_spp$Acropora$taxonname)
Define well known text area's. I used this site http://arthur-e.github.io/Wicket/sandbox-gmaps3.html to draw then copy/paste the well known text area's for each of the oceans. You can paste them in to the little box on that site to visualize them. I very roughly did these, whereas you would want to redo them probably. For some reason drawing a lot of points to define the polygon is giving back errors in the code below where you search for occurrences with the geometry
parameter - it could just be that URL string is too long. I'll see if GBIF folks know.
pac_ocean <- 'POLYGON((177.890625 47.372314620566925,-149.0625 58.33545085930665,-81.5625 -15.490738864633403,-82.265625 -57.44199339152663,179.296875 -57.061643560142365,177.890625 47.372314620566925))'
indian_ocean <- 'POLYGON((59.4140625 18.443135757230902,53.0859375 -16.50456606887792,40.4296875 -36.48755716938576,34.453125 -53.24878214338736,120.234375 -52.3990673029333,106.875 -17.177530993362254,59.4140625 18.443135757230902))'
red_sea <- 'POLYGON((42.7587890625 13.641315928714524,42.4072265625 16.610531912472258,38.935546875 20.936430557693942,35.1123046875 27.737630523005347,33.92578125 27.347983712830867,38.0126953125 19.20288950660436,39.5947265625 16.231157205021905,42.7587890625 13.641315928714524))'
You can also visualize WKT area with a in rough draft function wkt_vis
from spocc
wkt_vis(red_sea)
Search for occurrence records for all taxa
tt <- occ(query = spplist, from = "gbif", geometry = pac_ocean, limit = 10)
Check data for a single species
tt$gbif$data$Acropora_nasuta
Combine to a single data.frame
dat <- occ2df(tt)
head(na.omit(dat))
name longitude latitude prov
8 Acropora humilis -149.8167 -17.47670 gbif
9 Acropora humilis -149.7650 -17.48360 gbif
10 Acropora humilis -169.5248 16.75819 gbif
11 Acropora humilis -169.5248 16.75819 gbif
12 Acropora humilis -136.2333 16.63330 gbif
13 Acropora humilis 179.2160 -8.51600 gbif