Spaces:
Sleeping
Sleeping
:lion:
Browse files- inat-ranges.R +3 -2
- test.R +12 -5
inat-ranges.R
CHANGED
@@ -6,8 +6,6 @@ library(mapgl)
|
|
6 |
|
7 |
richness <- function(inat, aoi, rank = NULL, taxon = NULL) {
|
8 |
|
9 |
-
taxa <- open_dataset("https://minio.carlboettiger.info/public-inat/taxonomy/taxa.csv", format = "csv", recursive = FALSE)
|
10 |
-
|
11 |
hash <- digest::digest(list(aoi, rank, taxon))
|
12 |
s3 <- paste0("s3://public-data/cache/inat/", hash, ".h3j")
|
13 |
|
@@ -15,7 +13,10 @@ richness <- function(inat, aoi, rank = NULL, taxon = NULL) {
|
|
15 |
|
16 |
# filter
|
17 |
if (!is.null(rank) && !is.null(taxon)) {
|
|
|
|
|
18 |
inat <- taxa |>
|
|
|
19 |
filter(.data[[rank]] == taxon) |>
|
20 |
select(taxon_id) |>
|
21 |
inner_join(inat, by = "taxon_id")
|
|
|
6 |
|
7 |
richness <- function(inat, aoi, rank = NULL, taxon = NULL) {
|
8 |
|
|
|
|
|
9 |
hash <- digest::digest(list(aoi, rank, taxon))
|
10 |
s3 <- paste0("s3://public-data/cache/inat/", hash, ".h3j")
|
11 |
|
|
|
13 |
|
14 |
# filter
|
15 |
if (!is.null(rank) && !is.null(taxon)) {
|
16 |
+
taxa <- open_dataset("https://minio.carlboettiger.info/public-inat/taxonomy/taxa.parquet",
|
17 |
+
recursive = FALSE)
|
18 |
inat <- taxa |>
|
19 |
+
rename(taxon_id = id) |>
|
20 |
filter(.data[[rank]] == taxon) |>
|
21 |
select(taxon_id) |>
|
22 |
inner_join(inat, by = "taxon_id")
|
test.R
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
## Illustrate/test core app functionality without shiny
|
2 |
library(dplyr)
|
3 |
library(duckdbfs)
|
@@ -18,18 +20,23 @@ aoi <- spData::us_states
|
|
18 |
aoi <- spData::world
|
19 |
|
20 |
# publish richness at the aoi (bbox or poly)
|
21 |
-
richness(inat, aoi)
|
22 |
-
m <-
|
23 |
-
|
|
|
24 |
library(htmlwidgets)
|
25 |
htmlwidgets::saveWidget(m, "total-richness.html")
|
26 |
|
27 |
|
28 |
# publish richness at the aoi (bbox or poly)
|
29 |
-
richness(inat, aoi, rank = "class", taxon = "Aves")
|
30 |
-
m <- richness_map()
|
31 |
htmlwidgets::saveWidget(m, "aves-richness.html")
|
32 |
|
|
|
|
|
|
|
|
|
33 |
|
34 |
|
35 |
## UGH can't deal with antimeridian
|
|
|
1 |
+
|
2 |
+
|
3 |
## Illustrate/test core app functionality without shiny
|
4 |
library(dplyr)
|
5 |
library(duckdbfs)
|
|
|
20 |
aoi <- spData::world
|
21 |
|
22 |
# publish richness at the aoi (bbox or poly)
|
23 |
+
url <- richness(inat, aoi)
|
24 |
+
m <- maplibre() |> add_draw_control()
|
25 |
+
m <- richness_map(url = url)
|
26 |
+
m
|
27 |
library(htmlwidgets)
|
28 |
htmlwidgets::saveWidget(m, "total-richness.html")
|
29 |
|
30 |
|
31 |
# publish richness at the aoi (bbox or poly)
|
32 |
+
url <- richness(inat, aoi, rank = "class", taxon = "Aves")
|
33 |
+
m <- richness_map(url = url)
|
34 |
htmlwidgets::saveWidget(m, "aves-richness.html")
|
35 |
|
36 |
+
# publish richness at the aoi (bbox or poly)
|
37 |
+
richness(inat, aoi, rank = "class", taxon = "Mammalia")
|
38 |
+
m <- richness_map()
|
39 |
+
htmlwidgets::saveWidget(m, "mammals-richness.html")
|
40 |
|
41 |
|
42 |
## UGH can't deal with antimeridian
|