ailich / GLCMTextures

This R package calculates the most common gray-level co-occurrence matrix (GLCM) texture metrics used for spatial analysis on raster data.
https://ailich.github.io/GLCMTextures/
GNU General Public License v3.0
12 stars 4 forks source link

Add examples #14

Closed rhijmans closed 2 years ago

rhijmans commented 2 years ago

The help files do not have examples. ?glcm_textures could have something like this:

r<- rast(volcano, extent= ext(2667400, 2667400 + ncol(volcano)*10, 6478700, 6478700 + nrow(volcano)*10), crs = "EPSG:27200") 
rq <- quantize_raster(r = r, n_levels = 16, method = "equal prob")
txt <- glcm_textures(rq, w = c(3,5), n_levels = 16, quantization = "none", shift = c(1,0))
plot(txt)
ailich commented 2 years ago

Thanks for the suggestion. Added examples to both glcm_textures and quantize_raster. I will add some examples to the other functions too, but those are the "main" two functions.

rhijmans commented 2 years ago

This example fails:

library(GLCMTextures)
r <- rast(volcano, extent= ext(2667400, 2667400 + ncol(volcano)*10, 6478700, 6478700 + nrow(volcano)*10), crs = "EPSG:27200")
#Error in rast(volcano, extent = ext(2667400, 2667400 + ncol(volcano) *  : 
#  could not find function "rast"

I think because terra is in "Imported" but not in "Depends"

you could change that, or add library(terra) to the example.

ailich commented 2 years ago

Thanks, I added library(terra) to the examples that need it and added examples for the other functions as well.