valentinitnelav / satellite-image-classification-r

Exercise with pixel based supervised classification of Sentinel-2 multispectral images in R. Comparing Random Forests, SVM and Neural Networks.
https://valentinitnelav.github.io/satellite-image-classification-r/
19 stars 17 forks source link

No data in the cache/temp directory #1

Closed valentinitnelav closed 4 years ago

valentinitnelav commented 4 years ago

Dear Valentin,

[...] I am working on deforestation monitoring and I was lucky to find its github repository, I am checking its code (https://github.com/valentinitnelav/satellite-image-classification-r) because I would like to reproduce the example for better understand your code and be able to adapt it to my work; but I have problems with the lack of data found in the cache and cache/temp directory. Then, please, can you share this information to reproduce your example Thank you very much in advance for your time and your prompt response.

> brick_for_prediction <- brick("./cache/temp/r_tmp_2019-04-02_215609_8472_60792.gri")
Error in .local(.Object, ...) : 

Error in .rasterObjectFromFile(x, objecttype = "RasterBrick", ...) : 
  Cannot create a RasterLayer object from this file. (file does not exist)
valentinitnelav commented 4 years ago

Note that you do not have to use the `cache/temp folder, so follow the instructions as per the html output/tutorial, not the Rmd file.

Or, in the section where you tried to read data from cache/temp (see below as well), read everything into your R environment, except brick_for_prediction and go after directly to the section Resample bands in the HTML tutorial.

# For avoiding long waiting time, read already saved/cached objects
records <- readRDS(file = "./cache/records.rds")
datasets <- readRDS(file = "./cache/datasets.rds")
rst_crop_lst <- lapply(list.files("./data/crop",
                                  pattern = "^B.{2}\\.tif$",
                                  full.names = TRUE),
                       FUN = raster)
names(rst_crop_lst) <- sapply(rst_crop_lst, names)
# brick_for_prediction <- brick("./cache/temp/r_tmp_2019-04-02_215609_8472_60792.gri")
model_rf <- readRDS(file = "./cache/model_rf.rds")
model_svm <- readRDS(file = "./cache/model_svm.rds")
model_nnet <- readRDS(file = "./cache/model_nnet.rds")

Every time I test my code and produce a HTML from the Rmd I had to cache the intermediary results in cache/temp, so that I do not waste a lot of time (download the rasters, crop them, etc). The cache data can be big, is nevertheless stored in this repository here.