Skip to content

Instantly share code, notes, and snippets.

rglobi::query('START predatorTaxon = node:taxons(name="Homo sapiens")
MATCH predatorTaxon<-[:CLASSIFIED_AS]-predator-[:ATE|PREYS_ON]->prey-[:CLASSIFIED_AS]->preyTaxon,
predator-[:COLLECTED_AT]->location-[:HAS_ENVIRONMENT]->envo
WHERE envo.name= "coast"
WITH envo, preyTaxon, predatorTaxon
MATCH preyTaxon<-[:CLASSIFIED_AS]-pred2-[:ATE]->prey2-[:CLASSIFIED_AS]->preyOfPreyTaxon
RETURN envo.externalId, envo.name, preyTaxon.commonNames?, preyTaxon.path?, predatorTaxon.name as predatorName, preyTaxon.name as preyName, count(distinct preyOfPreyTaxon.name) as preyOfPreyCount')
<html>
<head>
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/themes/css/cartodb.css"/>
<script src="http://libs.cartocdn.com/cartodb.js/v3/cartodb.js"></script>
<script src="https://rawgit.com/jhpoelen/eol-globi-data-js/master/globi-data-dist.js"></script>
<style>
html, body {
width: 100%;
height: 100%;
padding: 0;
@jhpoelen
jhpoelen / .block
Last active March 1, 2016 02:03
Phoibos2 Specimen Identifier Graph (manual only)
license: gpl-3.0
@jhpoelen
jhpoelen / .block
Last active March 1, 2016 01:10 — forked from mbostock/.block
Phoibos2 Specimen Identifier Graph (small)
license: gpl-3.0
@jhpoelen
jhpoelen / McLarenFoodWeb.R
Created February 16, 2016 22:18
McLaren Park Observations and Interactions
# retrieve trophic interactions related to species
# that were recorded at or near McLaren Park
# using GloBI and GBIF
install.packages(c('rglobi', 'rgbif'))
mcLarenWKT <- 'POLYGON((-122.435 37.726,-122.406 37.726, -122.406 37.710, -122.435 37.710, -122.435 37.726))'
mcLarenObs <- rgbif::occ_search(geometry= mcLarenWKT)
gbifSpeciesKeys <- na.omit(unique(mcLarenObs$data$speciesKey))
@jhpoelen
jhpoelen / filter.json
Last active August 29, 2015 14:23
GBIF download script - requests archive that includes all of GBIF spatial records without (spatial) issues.
{
"creator":"jhpoelen",
"notification_address": ["[email protected]"],
"predicate":
{
"type":"and",
"predicates": [
{"type":"equals","key":"HAS_GEOSPATIAL_ISSUE","value":"false"},
{"type":"equals","key":"HAS_COORDINATE","value":"true"}
]
#install rglobi (see ropensci.org for more info)
install.packages(c('rglobi'))
# read species list after exporting as csv
krak <- read.csv(file='Krak_list_DELETE.csv', stringsAsFactors=F)
# pick unique families
taxonList <- unique(krak$Family)
# find and aggregate interactions for each species . . . one by one
interactions <- Reduce(function(accum, taxon) {
@jhpoelen
jhpoelen / gbif_globi_example.R
Last active August 29, 2015 14:20
Example of how to use GBIF to generate a species list for a specific are and use GloBI to retrieve interactions for those species. Please refer to http://ropensci.org to learn more about the packages.
# install rgbif and rglobi libraries (see http://ropensci.org for more info)
install.packages(c('rgbif', 'rglobi'))
# define geometric bounding box (around california)
geo1 <- "POLYGON((-126 32, -114 32, -114 41, -126 41, -126 32))"
# retrieve a bunch of occurrences of Mustelidae with the geometric area
mustelidaeOcc <- rgbif::occ_search(scientificName='Mustelidae', fields='minimal', geometry = geo1)$data
# get any interactions records involving unique taxa occurrences at bbox geo1
@jhpoelen
jhpoelen / interactMap.geojson
Created January 20, 2015 17:50
interaction map
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jhpoelen
jhpoelen / createDistributionMap.R
Last active August 29, 2015 14:10
Generate Global Biotic Interaction Distribution Maps
# see Jorrit H. Poelen, James D. Simons and Chris J. Mungall. (2014). Global Biotic Interactions: An open infrastructure to share and
# analyze species-interaction datasets. Ecological Informatics. http://dx.doi.org/10.1016/j.ecoinf.2014.08.005
# rasterize locations, retrieve stats for bounding boxes, plot graphs
if (!'package:raster' %in% search()) {
install.packages(c('raster','maps'), repos='http://cran.us.r-project.org')
library('raster')
library('maps')
}