Downloading data using the galah package
Javad Vahdat
2024-07-31
download_sighting_data_from_galah.Rmd
Introduction
This manual provides a step-by-step guide on how to download data for
the species for example Sepia apama (Giant Cuttlefish) using
the galah
package in R. The galah
package is
an interface to the Atlas of Living Australia (ALA) APIs, which allows
you to query and download biodiversity data.
Prerequisites
Ensure you have R and RStudio installed on your computer. You’ll also need an internet connection to download the data.
Installation
First, you need to install the galah
package if you
haven’t already. You can do this by running the following command in
your R console:
install.packages("galah")
Configuration
Before you can download data, you need to configure the
galah
package with your email. This email will be used to
identify your requests to the ALA servers.
galah_config(email = "youremail@email.com")
Replace "youremail@email.com"
with your own email
address.
Downloading Sepia apama Data
You can now download data for Sepia apama by using a series
of galah
functions. Here’s the complete code to do so:
sepia <- galah_call() |>
galah_identify("Sepia apama") |>
galah_select(basisOfRecord, recordedBy, recordedByID, eventType, group = c("basic", "event")) |>
atlas_occurrences()
Explanation of the Code
-
galah_call()
: Initializes the call to the ALA API. -
galah_identify("Sepia apama")
: Specifies the species of interest. -
galah_select(...)
: Selects specific fields to download. In this case, we are selectingbasisOfRecord
,recordedBy
,recordedByID
,eventType
, along with groupsbasic
andevent
. -
atlas_occurrences()
: Executes the query and retrieves the occurrence data.
Saving the Data
Once you have downloaded the data, you might want to save it for
future use. You can do this using the save
function:
save(sepia, file = "data-raw/sepia.RDA")
This will save the data to a file named sepia.RDA
in the
data-raw
directory. You can load this data in future
sessions using:
load("data-raw/sepia.RDA")