GeoMOER / geoAI

Module on geospatial data prediction and remote sensing of the Honour Degree Programm „AI und Entrepreneurship"
MIT License
0 stars 0 forks source link

GeoAI_2021_unit_03_EX_Spatial_prediction #5

Open Baldl opened 2 years ago

GeoKL commented 2 years ago

Hello, whenever I try to run prediction <- raster::predict(rasterStack, ffsmodel, na.rm = TRUE) I get the Error message Warning in file(fn, "rb") : cannot open file 'C:\Users\Kathi\AppData\Local\Temp\RtmpyijrEy\raster\r_tmp_2021-12-01_121626_23620_45054.gri': No such file or directory Error in file(fn, "rb") : cannot open the connection

I tried reinstalling the raster package and running R as administrator.

The connection 'C:\Users\Kathi\AppData\Local\Temp\RtmpyijrEy\raster\r_tmp_2021-12-01_121626_23620_45054.gri' indeed does not exist (there is no RtmpyijrEy folder in Temp).

In the first code chunk of this EX I changed predictors = training[,3:9] to predictors = training[,2:9] to include the OBJ_ID column. Might that be the problem?

GeoKL commented 2 years ago

Hi, so I changed it back to predictors = training[,3:9] and ran the modell again and the chunk prediction <- raster::predict(rasterStack, ffsmodel, na.rm = TRUE) still does not run. Also it seems like other (or maybe all) raster functions do not work either. I always get this error message: Warning in file(fn, "rb") : cannot open file 'C:\Users\Kathi\AppData\Local\Temp\RtmpyijrEy\raster\r_tmp_2021-12-01_121626_23620_45054.gri': No such file or directory Error in file(fn, "rb") : cannot open the connection

I don't know what to do about this..

gisma commented 2 years ago

@GeoKL Actually the error message tells us that the predict function is not able to locate the raster stack file. You obvouisly did not run the setup function. At the end of the script a temporary folder is set which "stabilize" for raster operation . However in this case you are running the predict on a stack that one was in the temporary folder under your user account. You need to fix this to a non temporary folder.

GeoKL commented 2 years ago

Thanks, you're right, since there was already a setup included in the EX (which has now changed), I did not include my normal setup (next time I will). But I ran

set raster temp path

raster::rasterOptions(tmpdir = envrmt$path_tmp) before every try, which is what you mean by setting a temporary folder right?

Now I also included my normal setup skript and I still get the Error message. For example, when I try to run

raster::plotRGB(rasterStack) Warning in file(fn, "rb") : cannot open file 'C:\Users\Kathi\AppData\Local\Temp\RtmpyijrEy\raster\r_tmp_2021-12-01_121626_23620_45054.gri': No such file or directory Error in file(fn, "rb") : cannot open the connection

So you said, I have to fix my folder to a non temporary folder. How do I do that?

gisma commented 2 years ago
Muenchj4 commented 2 years ago

@gisma I tried to run the forward feature selection model based on leave location out cross validation with my extracted data consisting of 20 polygons (10 of class "building" and 10 of class "other"). But it was not able to finish and told me: "Something is wrong; all the Accuracy metric values are missing: Accuracy Kappa
Min. : NA Min. : NA
1st Qu.: NA 1st Qu.: NA
Median : NA Median : NA
Mean :NaN Mean :NaN
3rd Qu.: NA 3rd Qu.: NA
Max. : NA Max. : NA
NA's :1 NA's :1
Error: Stopping In addition: There were 11 warnings (use warnings() to see them)" How can I tackle this problem and how can I put the accuracy metric values into the model to calculate on their base?

Muenchj4 commented 2 years ago

@gisma I now tried to run the ramdomly_goog_model script bevor and hoped the accuracy value would be used in the ffsmodel, but this time I got the message: Error in summary.connection(connection) : invalid connection What could be the reason? And how can I transfer this obvious invalid connection into a valid connection?