bioXgeo / geodiv

Other
11 stars 2 forks source link

Example Code for texture_image() produces an empty raster #16

Open BlueGrisGris opened 6 months ago

BlueGrisGris commented 6 months ago

Hello, Just started looking into geodiv for my research. When I tried to run the example code for texture_image(), I get a raster filled with Inf. This also occurs when I apply the function to my own data. Example:

> help(texture_image)
> 
>      # import raster image
>      data(normforest)
>      normforest <- terra::unwrap(normforest)
>      
>      # crop raster to smaller area
>      x <- terra::crop(normforest, terra::ext(normforest[1:100, 1:100, drop = FALSE]))
>      
>      # get a surface of root mean square roughness
>      sa_img <- texture_image(x = x, window = 'square',
+      size = 5, metric = 'sa',
+      parallel = TRUE, ncores = 1, nclumps = 20)
[1] "Beginning calculation of metrics over windows..."
Total time to calculate metrics: 1.361829
>      
>      # plot the result
>      terra::plot(sa_img)
> sa_img
class       : SpatRaster 
dimensions  : 100, 100, 1  (nrow, ncol, nlyr)
resolution  : 0.0002694946, 0.0002694946  (x, y)
extent      : -123, -122.9731, 43.07305, 43.1  (xmin, xmax, ymin, ymax)
coord. ref. : lon/lat WGS 84 
source(s)   : memory
name        : summer_ndvi_p45_r30_2000_2016_30m 
min value   :                     1.797693e+308 
max value   :                               Inf 
> 

Thanks!

biodiverCD-2 commented 4 months ago

I am having the same issue. It seems to occur with some surface metrics and not others.

@AnnieCooper @adammwilson @plzmsu