I am having an issue running the som_pam function where I a get the Error: [] lengths of of cells and values do not match message.
Upon examining the code for som_pam and running the code line by line I found out that the issue occurs at r.som[idx] <- terr.som$SOM$unit.classif. Essentially, for some reason the number of values don't match, i.e. length(values(r.som)) == length(terr.som$SOM$unit.classif) is FALSE.
Can you think of a reason why this may be occurring? Are there parameters I should alter in the som_gap function as I assume something is happening here where the number of cells in the input rasters is being altered when producing the classification units.