Skip to content

Instantly share code, notes, and snippets.

@larsgw
Last active May 8, 2025 15:10
Show Gist options
  • Save larsgw/1ce8ed35bcee00902fe127ca73989a2f to your computer and use it in GitHub Desktop.
Save larsgw/1ce8ed35bcee00902fe127ca73989a2f to your computer and use it in GitHub Desktop.
Area of different BioBlitzes in the Biodiversity Challenge 2025 on Observation.org
BioBlitz Area (km2)
Vytautas Magnus University Agriculture Ac. 2025 33.48
WUR 2025 26.26
University of Reading 2025 14.1
AgroParisTech 2025 13.44
KU Leuven 2025 11.41
Uni. of Life and Env. Science Ukraine (UBIP) 2025 5.56
Hochschule Geisenheim University 2025 3.2
UniLaSalle 2025 2.7
Aeres Hogeschool 2025 1.63
Uni of Nat. Resources and Life Sci. (Boku) 2025 1.61
Radboud universiteit 2025 1.29
University of Trás-os-Montes and Alto Douro (UTAD) 1.04
University of Latvia 2025 0.96
Warsaw University of Life Sciences 2025 0.72
Bordeaux Science Agro 2025 0.5
Czech University of Life Sciences 2025 0.43
Uni of Agr Sci and Vet Med of Bucharest 2025 0.38
const { promises: fs, existsSync: exists } = require('fs')
const path = require('path')
const { JSDOM } = require('jsdom')
const turf = require('@turf/turf')
const CACHE_FILE = path.join(__dirname, 'cache.json')
let cache
async function fetchText (url, options) {
if (!cache) {
if (exists(CACHE_FILE)) {
cache = JSON.parse(await fs.readFile(CACHE_FILE, 'utf8'))
} else {
cache = {}
}
}
if (cache.hasOwnProperty(url)) {
// console.error('Using cache...')
} else {
console.error('Fetching over HTTP...', url)
cache[url] = await fetch(url, options).then(response => response.text())
}
return cache[url]
}
async function fetchHtml (url, options) {
return fetchText(url, options).then(text => (new JSDOM(text, { url })).window.document)
}
async function main () {
const index = await fetchHtml('https://observation.org/bioblitz/categories/biodiversity-challenge-2025/')
const bioblitzes = index.querySelectorAll('table tbody td:nth-child(2) a')
const table = []
for (const bioblitz of bioblitzes) {
const map = await fetchHtml(bioblitz.href)
const geojson = JSON.parse(map.getElementById('geojson').textContent)
const area = turf.area(geojson)
table.push({ name: bioblitz.textContent, area })
}
table.sort((a, b) => b.area - a.area)
console.log(['BioBlitz', 'Area (km2)'].join())
for (const { name, area } of table) {
console.log([name, Math.floor(area / 1e4) / 1e2].join())
}
}
main().catch(console.error).finally(() => {
return fs.writeFile(CACHE_FILE, JSON.stringify(cache, null, 2))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment