Skip to contents

spdgt.core provides reference data lookups that feed directly into spdgt.sight, SpeedGoat’s package for sightability survey data and analysis. This vignette shows the typical workflow: discovering reference data with spdgt.core, then using it in spdgt.sight.

Setup

Both packages authenticate through spdgt.auth. Loading either package triggers the login flow if needed.

library(spdgt.core)
library(spdgt.sight)

Discovering your data

Before querying survey data, you need to know your species, analysis units, and survey types. spdgt.core lookups make this easy.

Species

Start by listing the species configured for your project:

Pick the one you want to work with:

sp_id <- lkup_species_id("Mule Deer")
sp_id
#> [1] 1

Analysis units and management units

DAUs (analysis units) and GMUs (management units) are species-specific. View what’s available:

lkup_dau(species_id = sp_id)
lkup_gmu(species_id = sp_id)

# Filter GMUs to a particular DAU
lkup_gmu(species_id = sp_id, dau_name = "Area 1")

Survey types

Survey types are also species-specific:

lkup_survey_type(species_id = sp_id)

st_id <- lkup_survey_type_id("Sightability", species_id = sp_id)
st_id
#> [1] 9

Querying survey data

With IDs in hand, use spdgt.sight to query survey data. spdgt.sight functions accept names directly (they use spdgt.core under the hood), but using IDs avoids repeated lookups when making multiple calls.

Listing surveys

surveys <- sight_read_surveys(
  species = "Mule Deer",
  survey_type = "Sightability"
)
surveys

Reading observations

sight_read_entries() returns individual sighting records:

entries <- sight_read_entries(
  species = "Mule Deer",
  survey_type = "Sightability",
  bio_year = 2024
)
entries

Getting analysis-ready data

sight_read_data() joins observations with design information to produce data ready for a sightability model:

analysis_data <- sight_read_data(
  species = "Mule Deer",
  survey_type = "Sightability",
  bio_year = 2024
)
analysis_data

Fitting a sightability model

sight_fit_model() runs the model and returns population estimates:

estimates <- sight_fit_model(
  species = "Mule Deer",
  spatial_focus = "DAU",
  bio_year = 2024,
  analysis_unit = "Area 1",
  survey_type = "Sightability",
  model = "Mule Deer"
)
estimates

For a richer summary including data diagnostics:

summary <- sight_fit_summary(
  species = "Mule Deer",
  spatial_focus = "DAU",
  bio_year = 2024,
  analysis_unit = "Area 1",
  survey_type = "Sightability",
  model = "Mule Deer"
)

Building Shiny dropdowns

spdgt.core _opts functions return named integer vectors designed for shiny::selectInput(). This makes it easy to build interactive UIs backed by spdgt.sight:

# In a Shiny UI
selectInput("species", "Species", choices = lkup_species_opts())

# Once a species is selected, populate dependent dropdowns
selectInput("dau", "Analysis unit",
  choices = lkup_dau_opts(species_id = input$species)
)
selectInput("survey_type", "Survey type",
  choices = lkup_survey_type_opts(species_id = input$species)
)
selectInput("strata", "Strata",
  choices = lkup_strata_opts(
    species_id = input$species,
    survey_type_id = input$survey_type
  )
)

These reactive dropdowns cascade: selecting a species populates the available DAUs, survey types, and strata automatically.

Checking connectivity

Before building a workflow, verify that both APIs are reachable:

sight_check_api()

This runs diagnostic checks for authentication, counts API access, and sightability API access.