Repository navigation
added the viirs LAI download and mosaicing features into pecan. - #4211
Conversation
| #' @author Dongchen Zhang | ||
| #' @importFrom purrr %>% | ||
| merge_image_tiles <- function(in.path, | ||
| doi = doi, |
There was a problem hiding this comment.
since this is a new function argument, it makes sense for this to have a default, but it's unclear what this specific default is pointing to. Would a NULL be a better default?
There was a problem hiding this comment.
Yeah. I added the NULL default throughout the script.
| #' target_format = ".tif") | ||
| #' } | ||
| gdal_conversion <- function(in_path, outfolder = NULL, band_name = NULL, tile_id = NULL, just_band_name = TRUE, target_format = ".tif") { | ||
| gdal_conversion <- function(in_path, doi, outfolder = NULL, band_name = NULL, tile_id = NULL, just_band_name = TRUE, target_format = ".tif") { |
There was a problem hiding this comment.
seems like new doi argument should have a default
|
@ashiklom Hi Alexy, for this PR, do you have a better way to get the projection info from the VIIRS LAI image than manually calculating it from the tile ID? |
I would expect this to be somewhere in the HDF5 attributes. Poke around the files with an HDF5 package (I like h5py or h5netcdf +Xarray in Python; ncdf4 or RNetCDF may work too and see if you find something that looks like an extent. GDAL might also hoist attributes into raster metadata somehow, so the terra object you create might have some attached attributes you can use for this. That said, your math is cheap and accurate so I think this is fine. |
| granules_href <- granules_href[-inds] | ||
| # This filter will only apply to the GEDI L4A product. | ||
| # Please let the author know if you find any exceptions. | ||
| if (doi == "10.3334/ORNLDAAC/2056") { |
There was a problem hiding this comment.
I would strongly advise against using DOI for this. In practice, nobody is going to remember the random digits at the front, so they will just have a lookup table like "VIIRS_LAI = ..., GEDI_AGB = ...". I would just key on human readable names like these directly, and error/warn quickly and loudly on any products passed that are not in that list.
If you must key on an unambiguous identifier, I would use the CMR collection ID, since that at least can be used for other CMR queries and is not dependent on exactly how DOIs get resolved (which I think is typically to product pages, not necessarily to specific collections).
There was a problem hiding this comment.
Thank you. I added the doi_to_product_name function to make it easier to map between DOI and product name. Using this function, I changed this line from a DOI match to an actual product name match, so it's easier for the user to understand what's happening here.
| doi_to_product_name <- function(doi = NULL) { | ||
| # if we doi is NULL. | ||
| if (is.null(doi)) { | ||
| return(doi) |
There was a problem hiding this comment.
note that all your uses of this function are in if statements (e.g., doi_to_product_name(doi) == "GEDI_L4A") and that comparisons like NULL == "GEDI_L4A" don't return FALSE they return logical(0). I'd propose that a NULL doi return a blank name ""
Added the VIIRS LAI download and mosaicing feature into pecan. Since the MODIS LAI product will soon be decommissioned, it's important to bring another global LAI product, the global VIIRS LAI product, on board. This PR ensures smooth downloading and post-processing of VIIRS H5 files. As before, the user can specify the data DOI and spatiotemporal range to download the data and combine all tiles.
Description
Motivation and Context
Review Time Estimate
Types of changes
Checklist: