Skip to content

Commit

Permalink
feat: [datasets/gbif] Add a query to uncover species found in one reg…
Browse files Browse the repository at this point in the history
…ion only (#388)
  • Loading branch information
happyhuman committed Jun 24, 2022
1 parent 02cc038 commit bd5a135
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions datasets/gbif/docs/queries/artifact.yaml
@@ -0,0 +1,5 @@
artifact:
title: Species Found Only in One Region
description: Using this query, we uncover which species have only been found in one single region.
vertical: environment
tier: free
19 changes: 19 additions & 0 deletions datasets/gbif/docs/queries/find_single_region_species.sql
@@ -0,0 +1,19 @@
WITH
intermediate AS (
SELECT
species,
COUNT(*) AS count,
MAX(decimallatitude) - MIN(decimallatitude) AS latitude_diff,
MAX(decimallongitude) - MIN(decimallongitude) AS longitude_diff
FROM
`bigquery-public-data.gbif.occurrences` TABLESAMPLE SYSTEM (100 PERCENT)
WHERE
decimallatitude IS NOT NULL AND decimallongitude IS NOT NULL
GROUP BY species)
SELECT *
FROM intermediate
WHERE
latitude_diff < 1 AND
longitude_diff < 1 AND
count > 1000
ORDER BY count DESC;

0 comments on commit bd5a135

Please sign in to comment.