spdgt.core provides cached reference data lookups and direct API access for the SpeedGoat count API. This vignette walks through common tasks: looking up species, finding management and analysis units, and resolving names to IDs.
Authentication
spdgt.core relies on spdgt.auth for authentication. You must be logged in before calling any functions. If you are not already authenticated, most functions will trigger the login flow automatically.
The lookup cache
Most spdgt.core functions rely on a set of reference tables that are fetched once and stored in memory for the session. The cache is built automatically the first time you call a lookup function, but you can also build it explicitly:
If data changes on the server during your session, rebuild the cache to pick up the updates.
Species lookups
Start by viewing the species available in your project:
This returns a tibble with columns like species_id,
species_name, and is_enabled. By default, only
enabled species are shown.
To get a named vector for use in a Shiny dropdown:
lkup_species_opts()
# returns a named vector like c("Mule Deer" = 1, ...)To resolve a species name to its integer ID:
lkup_species_id("Mule Deer")If you misspell a name, spdgt.core will suggest the closest match.
Age classes
Age classes are species-specific. Supply a species ID or name:
The tibble includes age_class, age_num,
age_min_months, age_max_months, and
is_first_reproduction.
Use lkup_age_opts() for a named vector and
lkup_age_id() to resolve a specific age class:
lkup_age_opts(species_id = 1)
lkup_age_id(age_class = "Adult", species_id = 1)Management units (GMU) and analysis units (DAU)
GMUs and DAUs are species-specific. DAUs are also versioned; by default the latest version is used.
# All GMUs for a species
lkup_gmu(species_id = 1)
# Filter GMUs to a particular DAU
lkup_gmu(species_id = 1, dau_name = "Area 1")
# DAU information
lkup_dau(species_id = 1, dau_name = "Area 1")
# Named vectors for dropdowns
lkup_gmu_opts(species_id = 1)
lkup_dau_opts(species_id = 1)Survey types, strata, and aircraft
These follow the same pattern. Survey types and strata are species-specific, while aircraft are project-wide:
lkup_survey_type(species_id = 1)
lkup_strata(species_id = 1, survey_type_name = "Sightability")
lkup_aircraft()Resolving names to IDs
Every lookup family has a _id function that converts a
name to its integer ID. These are useful when building API calls or
setting up analyses:
lkup_species_id("Elk")
lkup_gmu_id("Unit 011", species_id = 1)
lkup_dau_id("Area 1", species_id = 1)
lkup_survey_type_id("Sightability", species_id = 1)The underlying resolve_* functions do the same thing and
are available for programmatic use.
Direct API reads
When you need data that goes beyond the cached lookups, use the
lkup_read_* functions. These hit the API directly and
return tibbles:
lkup_read_region()
lkup_read_gmu(species_id = 1)
lkup_read_dau(species_id = 1)
lkup_read_subunit(dau_id = 10)
lkup_read_age(species_id = 1)For spatial data and sharing, see
vignette("spatial-data").