Skip to content

Conversation

@regetz
Copy link
Collaborator

@regetz regetz commented Feb 8, 2026

What

This PR adds vb_get_*() and vb_count_*() wrapper functions for the following new endpoints:

  • GET /taxon-importances
  • GET /stem-counts
  • GET /strata
  • GET /named-places
  • GET /roles
  • GET /user-datasets

... and also enables the use of cross-resource queries for plot observations associated with a given named place or user dataset, e.g. vb_get_plot_observations("ds.199635") to get all plot observations associated with dataset ds.199635.

Why

So that package users can conveniently leverage these new API features.

How

For each of the 6 new resource types:

  • Updated the table code lookup vector
  • Added a new vb_get_*() wrapper
  • Added a new vb_count_*() wrapper

Testing and documentation

  • Included roxygen-based documentation for all new functions, and generated man files
  • Added functional tests with JSON input fixtures as needed, for all new vb_get_*() and vb_count_*() functions
  • Added new sets of API integration and e2e tests
  • Updated these API tests with respect to the plot observation response schema
  • Added integration tests for the new cross-resource queries for plot observations
  • Verified that all tests pass, and test coverage is 100%
  • Verified that R check passes: devtools::check(cran=TRUE, remote = TRUE, incoming = TRUE)

Demo

Taxon importances
> vb_count_taxon_importances()
[1] 3599923

> vb_get_taxon_importances(limit=5)
# A tibble: 5 × 12
  tm_code  to_code  ob_code sr_code  stratum_name  cover cover_code basal_area
  <chr>    <chr>    <chr>   <chr>    <chr>         <dbl> <chr>           <int>
1 tm.67083 to.64982 ob.2948 sr.17458 Nonvascular  63.3   05                 NA
2 tm.67084 to.64982 ob.2948 NA       <All>        63.3   05                 NA
3 tm.67085 to.64983 ob.2948 sr.17458 Nonvascular   0.562 01                 NA
4 tm.67086 to.64983 ob.2948 NA       <All>         0.562 01                 NA
5 tm.67087 to.64984 ob.2948 NA       <All>         0.188 01                 NA
# ℹ 4 more variables: biomass <int>, inference_area <int>, stratum_base <int>,
#   stratum_height <int>
Stem counts
> vb_count_stem_counts()
[1] 600241

> vb_get_stem_counts(limit=5)
# A tibble: 5 × 12
  ob_code to_code  tm_code  sr_code  stratum_name sc_code diameter
  <chr>   <chr>    <chr>    <chr>    <chr>        <chr>      <dbl>
1 ob.3062 to.68185 tm.74081 sr.22374 Canopy       sc.2056     22
2 ob.3062 to.68185 tm.74081 sr.22374 Canopy       sc.2057     17.2
3 ob.3062 to.68185 tm.74081 sr.22374 Canopy       sc.2058     12.4
4 ob.3062 to.68185 tm.74081 sr.22374 Canopy       sc.2059     14.3
5 ob.3062 to.68185 tm.74081 sr.22374 Canopy       sc.2060     13.4
# ℹ 5 more variables: diameter_accuracy <int>, height <int>,
#   height_accuracy <int>, count <dbl>, taxon_area <int>
Strata
> vb_count_strata()
[1] 347097

> vb_get_strata(limit=5)
# A tibble: 5 × 11
  ob_code sr_code  name        height  base cover description sm_code
  <chr>   <chr>    <chr>        <int> <int> <dbl>       <int> <chr>
1 ob.2948 sr.17456 Tall Shrub      NA    NA     0          NA sm.5
2 ob.2948 sr.17457 Short Shrub     NA    NA     0          NA sm.5
3 ob.2948 sr.17458 Nonvascular     NA    NA    90          NA sm.5
4 ob.2948 sr.17459 Herbaceous      NA    NA     7          NA sm.5
5 ob.2948 sr.17460 Epiphyte        NA    NA     0          NA sm.5
# ℹ 3 more variables: stratum_method_name <chr>, sy_code <chr>,
#   stratum_type_name <chr>
Named places
> vb_count_named_places()
[1] 64563

> vb_get_named_places(limit=5)
# A tibble: 5 × 8
  np_code system                name  description code  owner rf_label obs_count
  <chr>   <chr>                 <chr>       <int> <chr> <int> <chr>        <dbl>
1 np.1    continent             AfriNA f        NA USLC pl0
2 np.2    area|country|territoAfriNA fc       NA USLC pl0
3 np.3    area|country|territoAfriNA fe       NA USLC pl0
4 np.4    area|country|territoAfriNA fq       NA USLC pl0
5 np.5    area|country|territoAfriNA ff       NA USLC pl0
Plot observations for a given named place
> vb_get_plot_observations("np.1000", limit=5)
# A tibble: 5 × 11
  author_plot_code pl_code  latitude longitude  area elevation country
  <chr>            <chr>       <dbl>     <dbl> <dbl>     <dbl> <chr>
1 016-01-0047      pl.79523     32.0     -81.8  1000        42 United States
2 016-01-0048      pl.79524     32.0     -81.8  1000        43 United States
3 016-01-0062      pl.79538     31.9     -82.1  1000        27 United States
4 016-01-0063      pl.79539     31.9     -82.1  1000        26 United States
5 016-01-0064      pl.79540     31.9     -82.1  1000        30 United States
# ℹ 4 more variables: state_province <chr>, ob_code <chr>,
#   author_obs_code <chr>, year <dbl>
Roles
> vb_count_roles()
[1] 21

> vb_get_roles(limit=5)
# A tibble: 5 × 3
  ar_code name         description
  <chr>   <chr>        <chr>
1 ar.16   Author       NA
2 ar.17   Contact      VegBank Contact Party
3 ar.18   PI           Primary Investigator
4 ar.19   Data Manager NA
5 ar.34   Classifier   NA
User datasets
> vb_count_user_datasets()
[1] 57

> vb_get_user_datasets(limit=5)
# A tibble: 5 × 10
  ds_code   accession_code     start                stop name  description type
  <chr>     <chr>              <dttm>              <int> <chr> <chr>       <chr>
1 ds.196903 VB.ds.196903.6A182005-08-13 23:49:13    NA exam"some plot… norm…
2 ds.196904 VB.ds.196904.2707… 2005-08-13 23:51:54    NA exam… "some plotnorm3 ds.196917 VB.ds.196917.OBCC2005-08-24 13:00:38    NA test2 ""          norm4 ds.199634 VB.ds.199634.CEGL2013-06-10 07:00:00    NA CEGLNA         norm5 ds.199635 VB.ds.199635.CEGL2013-06-10 07:00:00    NA CEGLNA         norm# ℹ 3 more variables: owner_label <chr>, owner_email <chr>, obs_count <dbl>
Plot observations for a given user dataset
> vb_get_plot_observations("ds.199635", limit=5)
# A tibble: 5 × 11
  author_plot_code pl_code  latitude longitude  area elevation country
  <chr>            <chr>       <dbl>     <dbl> <dbl>     <dbl> <chr>
1 002-01-0042      pl.79110     34.7     -79.2   200        52 United States
2 003-02-0082      pl.79271     34.7     -78.6  1000        29 United States
3 003-03-0085      pl.79297     34.6     -78.4  1000        20 United States
4 003-06-0101      pl.79388     34.8     -79.6  1000        80 United States
5 044-07-0613      pl.80450     34.3     -79.3  1000        22 United States
# ℹ 4 more variables: state_province <chr>, ob_code <chr>,
#   author_obs_code <chr>, year <dbl>

@regetz regetz self-assigned this Feb 8, 2026
@regetz regetz linked an issue Feb 8, 2026 that may be closed by this pull request
@regetz
Copy link
Collaborator Author

regetz commented Feb 9, 2026

Merging and moving forward :)

@regetz regetz merged commit db38da3 into develop Feb 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support newly added API GET endpoints

1 participant