The Geospatial Quality API (GQ API) is a REST API created to provide access to a set of basic geospatial assessment functions over sets of primary biodiversity records. This package, rgeospatialquality, is built as a wrapper for the GQ API. It provides native access to the methods of the API and allows to use its functions from within an R environment. Below I will use the , rgeospatialquality,and ,rgbif, package to retrieve occurence data and send it the GQ API.
In this documentation there is a single function which retrieves GBIF occurrence data of all terrestrial mammals in Australia and then sends all of them to the Geospatial Quality API. The function code is below.
FUNCTION<-function(){ if(requireNamespace("rgbif", quietly = TRUE)){ library(rgbif) d1 <- occ_data( country = "AU", # Country code for australia classKey= 359, # Class code for mammalia from = 'gbif', limit=5000, minimal=FALSE, hasCoordinate = T ) } if(requireNamespace("rgbif", quietly = TRUE)){ d1 <- d1$data } ## Cleaning the data . library(tidyr) d1<-d1 %>% drop_na(decimalLatitude,decimalLongitude,countryCode,scientificName,name) d1$scientificName<-d1$name #Caveat: while the API accepts scientific names as specified in the DarwinCore Standard, currently some tools only work if the "Genus"+"Specific Epithet" binomial is provided in this field. #Thus, instead of "Puma concolor (Linnaeus, 1771)", we recommend using just "Puma concolor" in the 'scientificName' field. #To follow the abve code copying the name to scientificName column #Checking the values to conform to the DarwinCore Standard #decimalLatitude: Value for the Latitude in decimal degrees format (e.g. 42.332) #decimalLongitude: Value for the Longitude in decimal degrees format (e.g. -1.833) #countryCode: 2 character ISO code for the country #scientificName if(requireNamespace("rgbif", quietly = TRUE)){ "decimalLatitude" %in% names(d1) "decimalLongitude" %in% names(d1) "countryCode" %in% names(d1) "scientificName" %in% names(d1) } #Pushing the data to Geospatial Quality API. #Hard limit of 1000 is set in the function add_flags. d5<-data.frame() library(rgeospatialquality) if(requireNamespace("rgbif")){ i=0 while(i<=4000) { if(i+1000>nrow(d1)) dat<-subset(d1[(i+1):nrow(d1),]) if(i+1000<=nrow(d1)) dat<-subset(d1[(i+1):(i+1000),]) i=i+1000 ddd1 <- (add_flags(dat)) ##Appending the data of flags in ome whole data frame d5<-rbind(d5,ddd1$flags) } } ##Appending the flagged data with original data. D<-cbind(d5,d1) #End }
Terrestrial mammals in Australia.
library(rgbif) library(maptools) d1 <- occ_data( country = "AU", # Country code for australia classKey= 359, # Class code for mammalia from = 'gbif', limit=500, minimal=FALSE ) d1 <- d1$data View(d1) plot(d1[,4:3], cex=1.0, col='blue') data(wrld_simpl) plot(wrld_simpl, add=TRUE)
The above map is of australia with location of terrestrial mammals on it.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.