Open rion-saeon opened 1 year ago
Hi @rion-saeon, thanks for filing this issue and the PRs. I'm on vacation until January, but will look at these in detail when I'm back.
Ali (the other primary author) and I are aware of this Best Practices document being quite out of date now. The MODIS data download and ddgridR
no longer being on CRAN are two of the major issues, but there are several more. Really this book need a complete and thorough update, which I have had time for over the past couple years. But I'm hoping to get to this in early 2023.
Thank you for the feedback Matt. Such an excellent book btw and looking forward to continuing with it. Regards,Sent from Rion's iPhone(Apologies for brevity and typos)On 12 Dec 2022, at 19:27, Matt Strimas-Mackey @.***> wrote: Hi @rion-saeon, thanks for filing this issue and the PRs. I'm on vacation until January, but will look at these in detail when I'm back. Ali (the other primary author) and I are aware of this Best Practices document being quite out of date now. The MODIS data download and ddgridR no longer being on CRAN are two of the major issues, but there are several more. Really this book need a complete and thorough update, which I have had time for over the past couple years. But I'm hoping to get to this in early 2023.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>
As per subject, this issue prevents passing the
max_lc_years
value as valid integer.Renaming to more descriptive files performs as expected:
new_names <- format(as.Date(names(tifs)), "%Y") %>% sprintf("modis_mcd12q1_umd_%s.tif", .) %>% file.path(dirname(tifs), .) file.rename(tifs, new_names)
Renamed files:
list.files("data/wt_example/modis/") [1] "modis_mcd12q1_umd_2010.tif" "modis_mcd12q1_umd_2011.tif" "modis_mcd12q1_umd_2012.tif" [4] "modis_mcd12q1_umd_2013.tif" "modis_mcd12q1_umd_2014.tif" "modis_mcd12q1_umd_2015.tif" [7] "modis_mcd12q1_umd_2016.tif" "modis_mcd12q1_umd_2017.tif" "modis_mcd12q1_umd_2018.tif" [10] "modis_mcd12q1_umd_2019.tif"
Stacking 10 renamed files as raster:
landcover <- list.files("data/wt_example/modis", "^modis_mcd12q1_umd", full.names = TRUE) %>% stack()
Extracting the year from file names and relabel names:
landcover <- names(landcover) %>% str_extract("(?<=modis_mcd12q1_umd_^)[0-9]{4}") %>% paste0("y", .) %>% setNames(landcover, .)
My result:
landcover
#class : RasterStack
#dimensions : 1969, 4301, 8468669, 10 (nrow, ncol, ncell, nlayers)
Additionalnlayers
created instead of9
#resolution : 463.3127, 463.3127 (x, y)
Res. is numeric instead of integer#extent : -8745491, -6752783, 3242262, 4154525 (xmin, xmax, ymin, ymax)
#crs : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +R=6371007.181 +units=m +no_defs
#names : yNA.1, yNA.2, yNA.3, yNA.4, yNA.5, yNA.6, yNA.7, yNA.8, yNA.9, yNA.10
The issue Min./Max. values don't print