Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [datasets/gbif] Add a query to uncover species found in one reg…
…ion only (#388)
- Loading branch information
1 parent
02cc038
commit bd5a135
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |