| Title: | Download Photos and Metadata from 'iNaturalist' |
|---|---|
| Description: | A lightweight interface to the 'iNaturalist' API (<https://www.inaturalist.org/pages/api+reference>) for downloading observation photos and exporting metadata to CSV. Supports filtering by taxon, place, user, and annotation. Note that downloaded photos retain their original licenses as set by 'iNaturalist' observers; users are responsible for respecting these licenses. |
| Authors: | Andrés Romero-Bravo [aut, cre] |
| Maintainer: | Andrés Romero-Bravo <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.2 |
| Built: | 2026-06-24 13:26:17 UTC |
| Source: | https://github.com/cran/inatpick |
A named lookup table for human-readable annotation labels and their
corresponding iNaturalist term_id and term_value_id pairs, for use
with inat_fetch().
inat_annotationsinat_annotations
A data frame with columns label, term_id, term_value_id.
A data frame with 20 rows and 3 columns (label, term_id,
term_value_id) listing all supported annotation labels and their
corresponding iNaturalist API term and term-value IDs.
Downloads all photos from a data frame returned by inat_fetch(), and
optionally saves observation metadata to a CSV file in the same folder.
inat_download( obs, out_dir, size = "large", metadata = TRUE, overwrite = FALSE, verbose = TRUE )inat_download( obs, out_dir, size = "large", metadata = TRUE, overwrite = FALSE, verbose = TRUE )
obs |
Data frame returned by |
out_dir |
Character. Directory to save images and metadata. Created if
it does not exist. There is no default: you must specify a path, e.g.
a folder in your working directory or |
size |
Character. Photo size: |
metadata |
Logical. If |
overwrite |
Logical. Re-download files that already exist (default
|
verbose |
Logical. Print progress messages (default |
Invisibly returns a data frame of photo URLs and local file paths.
## Not run: obs <- inat_fetch(taxon_id = 488444, place_id = 6783, user_login = "someuser") # Download photos and save metadata.csv to the same folder inat_download(obs, out_dir = file.path(tempdir(), "my_photos")) # Download photos only, no metadata inat_download(obs, out_dir = file.path(tempdir(), "my_photos"), metadata = FALSE) ## End(Not run)## Not run: obs <- inat_fetch(taxon_id = 488444, place_id = 6783, user_login = "someuser") # Download photos and save metadata.csv to the same folder inat_download(obs, out_dir = file.path(tempdir(), "my_photos")) # Download photos only, no metadata inat_download(obs, out_dir = file.path(tempdir(), "my_photos"), metadata = FALSE) ## End(Not run)
Retrieves all observations matching the given filters, handling pagination automatically. Multiple annotations can be passed as a character vector; each is fetched separately and the results combined.
inat_fetch( taxon_id, place_id = NULL, user_login = NULL, annotation = NULL, quality_grade = "any", year = NULL, month = NULL, licensed = NULL, per_page = 200, verbose = TRUE )inat_fetch( taxon_id, place_id = NULL, user_login = NULL, annotation = NULL, quality_grade = "any", year = NULL, month = NULL, licensed = NULL, per_page = 200, verbose = TRUE )
taxon_id |
Integer. iNaturalist taxon ID (e.g. |
place_id |
Integer or |
user_login |
Character or |
annotation |
Character vector of annotation labels, or a single integer
vector |
quality_grade |
Character. One of |
year |
Integer or |
month |
Integer (1–12) or |
licensed |
Logical or |
per_page |
Integer. Results per API page (max 200). |
verbose |
Logical. Print progress messages (default |
A data frame of observations with list-column photos.
inat_annotations for all annotation labels and IDs.
## Not run: # Single annotation obs <- inat_fetch(taxon_id = 488444, place_id = 6783, annotation = "flowers") # Multiple annotations obs <- inat_fetch(taxon_id = 51935, place_id = 6857, annotation = c("flowers", "green_leaves")) # See all available annotation labels inat_annotations ## End(Not run)## Not run: # Single annotation obs <- inat_fetch(taxon_id = 488444, place_id = 6783, annotation = "flowers") # Multiple annotations obs <- inat_fetch(taxon_id = 51935, place_id = 6857, annotation = c("flowers", "green_leaves")) # See all available annotation labels inat_annotations ## End(Not run)
Extracts key fields from observations returned by inat_fetch() and writes
them to a CSV file. Use path to save the CSV in the same folder as your
downloaded photos.
inat_metadata(obs, path, extra_cols = NULL)inat_metadata(obs, path, extra_cols = NULL)
obs |
Data frame returned by |
path |
Character. Output CSV file path. There is no default: you
must specify a path, e.g. a file in your working directory or
|
extra_cols |
Character vector of additional column names from |
Invisibly returns the metadata data frame.
The common_name column reflects iNaturalist's preferred_common_name,
which is typically in English but may vary depending on the taxon and
iNaturalist's locale settings.
## Not run: obs <- inat_fetch(taxon_id = 488444, place_id = 6783, user_login = "someuser") # Save photos and metadata to the same folder inat_download(obs, out_dir = file.path(tempdir(), "my_photos")) inat_metadata(obs, path = file.path(tempdir(), "my_photos", "metadata.csv")) ## End(Not run)## Not run: obs <- inat_fetch(taxon_id = 488444, place_id = 6783, user_login = "someuser") # Save photos and metadata to the same folder inat_download(obs, out_dir = file.path(tempdir(), "my_photos")) inat_metadata(obs, path = file.path(tempdir(), "my_photos", "metadata.csv")) ## End(Not run)
Returns matching places from iNaturalist, useful for finding the place ID
to pass to inat_fetch().
inat_search_place(name, n = 10)inat_search_place(name, n = 10)
name |
Character. Place name to search. |
n |
Integer. Maximum number of results to return (default 10). |
A data frame with columns id, name, display_name, and place_type.
## Not run: inat_search_place("United Kingdom") inat_search_place("Bolivia") ## End(Not run)## Not run: inat_search_place("United Kingdom") inat_search_place("Bolivia") ## End(Not run)
Returns matching taxa from iNaturalist, useful for finding the taxon ID
to pass to inat_fetch().
inat_search_taxon(name, rank = NULL, n = 10)inat_search_taxon(name, rank = NULL, n = 10)
name |
Character. Taxon name to search (common or scientific). |
rank |
Character or |
n |
Integer. Maximum number of results to return (default 10). |
A data frame with columns id, name, common_name, rank, and
observations_count, ordered by number of observations.
The common_name field reflects iNaturalist's preferred_common_name,
which is typically in English but may vary depending on the taxon and
iNaturalist's locale settings.
## Not run: inat_search_taxon("Drosera rotundifolia") inat_search_taxon("Drosera", rank = "genus") inat_search_taxon("sundew", rank = "species") ## End(Not run)## Not run: inat_search_taxon("Drosera rotundifolia") inat_search_taxon("Drosera", rank = "genus") inat_search_taxon("sundew", rank = "species") ## End(Not run)