HannaMeyer / CAST

Developer Version of the R package CAST: Caret Applications for Spatio-Temporal models
https://hannameyer.github.io/CAST/
108 stars 30 forks source link

add a focused error message for bandnames with leading numbers #50

Closed gisma closed 1 year ago

gisma commented 1 year ago

Since terra allows the layers in a stack to begin with a number, it will be automatically converted to an raster stack via newdata <- methods::as(newdata, "Raster") s. Due to the raster conventions this is done by adding a leading "X" to the layer name. Normally, however, model training and DI calculation have been carried out on the terra-stack without this leading "X".

The pull request checks whether the layer names have a leading number as name and points this out in the error message. Maybe this helps to avoid confusion about the message "names of newdata don't match names of train data in the model" which is thrown by default.