GithubHelp home page GithubHelp logo

dataton_sibecol_2019's People

Contributors

dependabot[bot] avatar ibartomeus avatar iremendoza avatar pakillo avatar saizhugo avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dataton_sibecol_2019's Issues

How to access gbif (example on bees)

#First we save family keys.
#Gbif----
library(rgbif)
spain_code <- isocodes[grep("Spain", isocodes$name), "code"]
portugal_code <- isocodes[grep("Portugal", isocodes$name), "code"]
apidae_key <- name_backbone(name="Apidae", rank = "family")$usageKey
andrenidae_key <- name_backbone(name="Andrenidae", rank = "family")$usageKey
halictidae_key <- name_backbone(name="Halictidae", rank = "family")$usageKey
colletidae_key <- name_backbone(name="Colletidae", rank = "family")$usageKey
megachilidae_key <- name_backbone(name="Megachilidae", rank = "family")$usageKey
stenotritidae_key <- name_backbone(name="Stenotritidae", rank = "family")$usageKey
melittidae_key <- name_backbone(name="Melittidae", rank = "family")$usageKey

#Second we fetch data
dat <- data.frame(name = NA, decimalLatitude = NA,
decimalLongitude = NA, scientificName = NA,
family = NA, genus = NA, species = NA,
year = NA, month = NA, day = NA, recordedBy = NA,
identifiedBy = NA, sex = NA)
for(i in c(apidae_key, andrenidae_key,
halictidae_key, colletidae_key,
megachilidae_key,
melittidae_key)){
temp <- occ_search(taxonKey= i,
return='data',
hasCoordinate=TRUE,
hasGeospatialIssue=FALSE,
limit=7000, #based on rounding up counts above
country = c(spain_code, portugal_code),
fields = c('name','decimalLatitude',
'decimalLongitude', 'scientificName',
'family','genus', 'species',
'year', 'month', 'day', 'recordedBy',
'identifiedBy', 'sex'))
if(length(temp$PT) == 1){
temp$PT <- data.frame(name = NA, decimalLatitude = NA,
decimalLongitude = NA, scientificName = NA,
family = NA, genus = NA, species = NA,
year = NA, month = NA, day = NA, recordedBy = NA,
identifiedBy = NA, sex = NA)
}
if(is.null(temp$ES$sex)){
temp$ES$sex <- NA
}
if(is.null(temp$PT$sex)){
temp$PT$sex <- NA
}
temp$ES <- temp$ES[,c('name','decimalLatitude',
'decimalLongitude', 'scientificName',
'family','genus', 'species',
'year', 'month', 'day', 'recordedBy',
'identifiedBy', 'sex')]
temp$PT <- temp$PT[,c('name','decimalLatitude',
'decimalLongitude', 'scientificName',
'family','genus', 'species',
'year', 'month', 'day', 'recordedBy',
'identifiedBy', 'sex')]
dat <- rbind(dat, as.data.frame(temp$ES), as.data.frame(temp$PT))
}
dat <- dat[-1,]
head(dat)
tail(dat)
dat <- dat[-nrow(dat),]
dim(dat) #6859

map an impressive map

library("leaflet")
dat <- read.csv("_data/data.csv")
dat$content <- paste("", dat$species, "", "
",
dat$family, "
", paste(dat$day, dat$month, dat$year, sep = "/"), "
", dat$recordedBy, "
", sep = "")
pal <- colorFactor(
palette = "Spectral",
domain = dat$family
) #maybe check family NA?
map <- leaflet(dat)
map1.5 <- addTiles(map)
map2 <- addCircleMarkers(map = map1.5, lng = dat$decimalLongitude,
lat = dat$decimalLatitude,
label = ~htmlEscape(species),
popup = ~content,
color = ~pal(family),
clusterOptions = markerClusterOptions())
addLegend(map = map2, position = "bottomright",
pal = pal, values = ~unique(dat$family),
title = "Bee family",
opacity = 1)

INaturalist

library(rinat)
bounds <- c(44.15, -10.13, 35.67, 4.76) #Spain
apidae <- get_inat_obs(taxon_name = "Apidae", geo = TRUE, maxresults = 7000 , bounds = bounds)
andrenidae <- get_inat_obs(taxon_name = "Andrenidae", geo = TRUE, maxresults = 7000 , bounds = bounds)
halictidae <- get_inat_obs(taxon_name = "Halictidae", geo = TRUE, maxresults = 7000 , bounds = bounds)
colletidae <- get_inat_obs(taxon_name = "Colletidae", geo = TRUE, maxresults = 7000 , bounds = bounds)
megachilidae <- get_inat_obs(taxon_name = "Megachilidae", geo = TRUE, maxresults = 7000 , bounds = bounds)
melittidae <- get_inat_obs(taxon_name = "Melittidae", geo = TRUE, maxresults = 7000 , bounds = bounds)
length(apidae$scientific_name) #1247
length(andrenidae$scientific_name) #164 (most genus only)
length(halictidae$scientific_name) #132
length(colletidae$scientific_name) #22
length(megachilidae$scientific_name) #173
length(melittidae$scientific_name) #11

inat <- rbind(apidae, andrenidae, halictidae, colletidae, megachilidae)
head(inat)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.