Why is crop sometimes introducing NAs on a categorical raster?

房东的猫 提交于 2019-12-06 10:56:04

The error message indicated something wrong happening with the Raster Attribute Table. The problem is related with special characters on the labels.

In particular, it appears that semicolumns (:) causes somehow a "splitting" of the class names in the cropped raster. Therefore, as soon as both

"Mosaic: Tree Cover / Other natural vegetation"

and

"Mosaic: Cropland / Tree Cover / Other natural vegetation"

pixels were included in the cropped extent, the RAT got corrupted due to multiple Mosaic labels, preventing correct saving of the file.

"Tidying" the class names using for example:

levels(r)[[1]]$CLASSNAMES <- stringr::str_replace(levels(r)[[1]]$CLASSNAMES , ":", "-")

solves the issue.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!