I've been using the glcm package in R to calculate various texture measures of raster data sets; however, I've been getting odd values for the correlation measure which should be constrained to -1 to +1. Although most values fall in this range, some pixels are assigned -Inf or Inf, and some pixels are assigned real numbers greater than 1. I've searched but haven't found anything about this issue and was wondering if anyone knew what would cause this and how to account for it. Below is a small reproducible example using R's volcano data set:
library(raster)
library(glcm)
rast<- raster(volcano)
textures<- glcm(rast)
hist(textures$glcm_correlation) #Most values in valid range (-1 to +1)
cellStats(textures$glcm_correlation, max) #Maximum Value is Inf
#[1] Inf
cellStats(textures$glcm_correlation, min) #Minimum Value is -Inf
#[1] -Inf
head(sort(unique(textures$glcm_correlation@data@values), decreasing = TRUE)) #There are real number values >1
#[1] Inf 5.839971 1.000000 1.000000 1.000000 1.000000
head(sort(unique(textures$glcm_correlation@data@values), decreasing = FALSE)) #-Inf is <0 but there are no real number values <0
#[1] -Inf -0.5735393 -0.5000000 -0.5000000 -0.4588315 -0.4335550