Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates get_biomass.R for issue #235 #237

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

georgewoolsey
Copy link

updates get_biomass.R for issue #235 to allow for vector, data frame, or matrix to be passed to the coords parameter

Description

The documentation states that the coords parameter should be:

a numeric vector of length 2 with longitude and latitude...or a matrix with 2 numerical columns giving the coordinates of each tree.

However, passing a matrix to the coords parameter with >1 rows is not supported due to the handling at these lines:

allodb/R/get_biomass.R

Lines 131 to 132 in 4207f86

long = coords[[1]],
lat = coords[[2]]

This pull request updates get_biomass.R to allow for a vector, data frame, or matrix to be passed to the coords parameter.

Related Issue

fixes the original issue posed by @ValentineHerr in #235

Example

dat <- scbi_stem1[1:100, ]
dat$long <- c(rep(-78, 50), rep(-80, 50))
dat$lat <- c(rep(40, 50), rep(41, 50))
# coords data frame
coords_df <- dat[, c("long", "lat")]
# coords matrix
coords_matrix <- as.matrix(coords_df)
# coords vector list
coords_vect <- c(-78,40)
# get_biomass data frame
bm_df <- get_biomass(
  dbh = dat$dbh,
  genus = dat$genus,
  species = dat$species,
  coords = coords_df
)
# get_biomass matrix
bm_matrix <- get_biomass(
  dbh = dat$dbh,
  genus = dat$genus,
  species = dat$species,
  coords = coords_matrix
)
# get_biomass vector list
bm_vect <- get_biomass(
  dbh = dat$dbh,
  genus = dat$genus,
  species = dat$species,
  coords = coords_vect
)
# check
identical(bm_df, bm_matrix, bm_vect)

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.

1 participant