
Query plots from database
query_plots.RdThis function queries a PostgreSQL inventory database to return a list of forest plots or individuals, with options to include associated traits and metadata, and to generate interactive maps.
Usage
query_plots(
plot_name = NULL,
tag = NULL,
country = NULL,
locality_name = NULL,
method = NULL,
extract_individuals = FALSE,
map = FALSE,
id_individual = NULL,
id_plot = NULL,
id_tax = NULL,
id_specimen = NULL,
interactive = TRUE,
show_multiple_census = FALSE,
show_all_coordinates = FALSE,
remove_ids = TRUE,
extract_traits = TRUE,
extract_individual_features = TRUE,
traits_to_genera = FALSE,
wd_fam_level = FALSE,
include_liana = FALSE,
extract_subplot_features = TRUE,
concatenate_stem = FALSE,
remove_obs_with_issue = TRUE,
include_issue = FALSE,
include_measurement_ids = FALSE,
exact_match = FALSE,
census_strategy = c("last", "first", "mean"),
output_style = c("auto", "minimal", "standard", "permanent_plot",
"permanent_plot_multi_census", "transect", "full"),
con = NULL,
con.taxa = NULL
)Arguments
- plot_name
Optional. A single string specifying plot name.
- tag
Optional. Tag identifier.
- country
Optional. A single string specifying country.
- locality_name
Optional. A single string specifying locality name.
- method
Optional. Method identifier.
- extract_individuals
Logical. Whether to extract individuals. Optional.
- map
Logical. Whether to generate map. Optional.
- id_individual
Optional. Individual identifiers.
- id_plot
Optional. Plot identifiers.
- id_tax
Optional. Taxonomic identifiers.
- id_specimen
Optional. Specimen identifiers.
- interactive
Logical. Whether the query should be interactive. TRUE by default.
- show_multiple_census
Logical. Whether to show multiple census data. Optional.
- show_all_coordinates
Logical. Whether to show all coordinates. Optional.
- remove_ids
Logical. Whether to remove ID columns from output. Optional.
- extract_traits
Logical. Whether to extract taxonomic traits. Optional.
- extract_individual_features
Logical. Whether to extract individual-level features. Optional.
- traits_to_genera
Logical. Whether to aggregate traits to genus level. Optional.
- wd_fam_level
Logical. Whether to use family-level wood density. Optional.
- include_liana
Logical. Whether to include lianas. Optional.
- extract_subplot_features
Logical. Whether to extract subplot features. Optional.
- concatenate_stem
Logical. Whether to concatenate multiple stems. Optional.
- remove_obs_with_issue
Logical. Whether to remove observations with issues. Optional.
- include_issue
Logical. Whether to include issue flags in aggregated output. Optional.
- include_measurement_ids
Logical. Whether to include measurement IDs in aggregated output. Optional.
- census_strategy
Character. Strategy for selecting census when `show_multiple_census = FALSE`. Options: "last" (default, most recent census), "first" (earliest census), or "mean" (average across all censuses). When "first" or "last" is selected, individuals recruited after the first census or dead before the last census will have NA values, reflecting biological reality.
- output_style
Character. Output formatting style. Options: "auto", "minimal", "standard", "permanent_plot", "permanent_plot_multi_census", "transect", "full". Optional.
- con
Optional database connection to main database. If NULL, will call call.mydb() to establish connection. If you've already connected with `mydb <- call.mydb()`, pass `con = mydb` to avoid re-prompting.
- con.taxa
Optional database connection to taxa database. If NULL, will check for `mydb.taxa` in calling environment, otherwise will call call.mydb.taxa() to establish connection. Pass explicitly to avoid credential prompts.
Value
A list or data frame containing plot data and associated information. When multiple components are requested, returns a list with elements like `extract`, `census_features`, `coordinates`, and `coordinates_sf`. If only one component is available, returns that component directly. Returns `NA` if no plots are found matching the criteria.