ecoinfaeet / dataton_sibecol_2019 Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
#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
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)
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)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.