install.packages("rinat")
It might be nice to share some of my iNaturalist observations in this blog. So I decided to create a backup of observations to quickly add them to my posts.
To get the data I first install the rinat
package:
Then I can download the observations from iNaturalist:
library(rinat)
library(dplyr)
Attaching package: 'dplyr'
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
<- get_inat_obs_user("NeoMapas",maxresults = 5000) user_obs
glimpse(user_obs)
Rows: 783
Columns: 37
$ scientific_name <chr> "Episyrphus viridaureus", "Rutilia", …
$ datetime <chr> "2024-05-26 11:19:00 +1000", "2024-04…
$ description <chr> "", "", "", "", "This was walking so …
$ place_guess <chr> "Frank Doyle Park, Randwick, NSW, AU"…
$ latitude <dbl> -33.90830, -33.91018, -33.91976, -33.…
$ longitude <dbl> 151.2416, 151.2383, 151.2601, 141.160…
$ tag_list <chr> "", "", "", "", "", "", "", "", "", "…
$ common_name <chr> "Black-banded Hoverfly", "", "Superb …
$ url <chr> "https://www.inaturalist.org/observat…
$ image_url <chr> "https://inaturalist-open-data.s3.ama…
$ user_login <chr> "neomapas", "neomapas", "neomapas", "…
$ id <int> 218262562, 211230093, 208409105, 2082…
$ species_guess <chr> "", "Rutilia", "Superb Fairywren", "B…
$ iconic_taxon_name <chr> "Insecta", "Insecta", "Aves", "Insect…
$ taxon_id <int> 363758, 341840, 12065, 543672, 748062…
$ num_identification_agreements <int> 0, 1, 2, 1, 1, 0, 1, 1, 1, 1, 2, 2, 1…
$ num_identification_disagreements <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
$ observed_on_string <chr> "2024-05-26 11:19:00+10:00", "2024-04…
$ observed_on <chr> "2024-05-26", "2024-04-29", "2024-04-…
$ time_observed_at <chr> "2024-05-26 01:19:00 UTC", "2024-04-2…
$ time_zone <chr> "Sydney", "Sydney", "Sydney", "Sydney…
$ positional_accuracy <int> 4, 3, NA, NA, NA, NA, NA, NA, NA, NA,…
$ public_positional_accuracy <int> 4, 3, NA, NA, NA, NA, NA, NA, NA, NA,…
$ geoprivacy <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
$ taxon_geoprivacy <chr> "", "", "open", "", "", "", "", "open…
$ coordinates_obscured <chr> "false", "false", "false", "false", "…
$ positioning_method <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
$ positioning_device <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
$ user_id <int> 74355, 74355, 74355, 74355, 74355, 74…
$ user_name <chr> "JR Ferrer-Paris", "JR Ferrer-Paris",…
$ created_at <chr> "2024-05-26 01:22:36 UTC", "2024-04-2…
$ updated_at <chr> "2024-05-26 01:23:00 UTC", "2024-05-0…
$ quality_grade <chr> "needs_id", "needs_id", "research", "…
$ license <chr> "CC-BY", "CC-BY", "CC-BY", "CC-BY", "…
$ sound_url <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, N…
$ oauth_application_id <int> 3, 3, NA, NA, NA, NA, NA, NA, NA, NA,…
$ captive_cultivated <chr> "false", "false", "false", "false", "…
Now I have a collection of photos in R and I can select one by title or any other criteria:
<- slice(user_obs, 500) selected_photo
And combine the R and markdown magic to show the photo in this document:
<- sprintf(
photo_md "![*%s* observed in %s by %s@iNaturalist](%s){.preview-image .lightbox}",
$species_guess,
selected_photo$place_guess,
selected_photo$user_login,
selected_photo$image_url
selected_photo
)
cat(photo_md)
If I want to save the information for future use in my blog, I need first to create a folder to hold the file, and then save the R object into an RDS file. Like this:
::i_am("posts/foto-collection.qmd") here
here() starts at /Users/z3529065/proyectos/personal/spatial-one
<- here::here("Rdata")
data_dir <- here::here("Rdata","iNaturalist-obs-NeoMapas.rds")
file_name saveRDS(file=file_name, user_obs)