traitecoevo / saltbush

saltbush is an R package for processing drone data to calculate spectral diversity metrics. It also calculates on-the-ground diversity from traditional surveys specifically from the AusPlots framework
GNU General Public License v3.0
1 stars 0 forks source link

wavelength names as input #8

Open wcornwell opened 1 week ago

wcornwell commented 1 week ago
metrics <- calculate_spectral_metrics(pixel_values, 
                                      masked = F, 
                                      wavelengths = colnames(pixel_values[, 2:6]), 
                                      rarefaction = F)

seems like the wavelength names could be handled inside the function instead of as an input? or not?

wcornwell commented 1 day ago

my idea seems incompatible with this for loop: https://github.com/traitecoevo/saltbush/blob/ddbe1904eb71fa721c9a440915e4eeb66da51131/R/calculate_spectral_metrics.R#L169

i guess the issue is where site should come in (from a user perspective)

adelegem commented 1 day ago

it could still be done within the function like wavelengths <- colnames(pixel_values)[2:(ncol(pixel_values) - 1)] however, i wonder if people rocked up with their own spectral dfs (ie. not from extract_pixel_values) and have different columns it wouldn't work. maybe wavelengths = NULL and if they have a different data structure they can provide their wavelength cols?

wcornwell commented 1 day ago

option 1: I guess we could leave it as it is and just say clearly in the documentation that the column names of the wavelengths must exactly match the inputs to the wavelengths variable. This isn't that different than how lm works, but it does allow for user spelling error to be annoying. We should probably work a bit on the error messages if we leave it this way.

option 2: make it so that all columns in the input data frame (except for special cases like aoi_id and site) are assumed to be wavelengths and then the names from the columns are used in the function.

option 3: ????