rasenior / ThermStats

Calculate statistics for thermal images in R
Other
3 stars 0 forks source link

Problem calculating neighbourhood weights #5

Closed rasenior closed 3 years ago

rasenior commented 4 years ago

Hello, while analyzing plant thermal images, I got below error ;

Getting patches ...calculating neighbourhood weights Error in spdep::knearneigh(cbind(df$x, df$y), k = 8) : knearneigh: fewer data points than k

Any idea to fix this error.

Originally posted by @washfaq in https://github.com/rasenior/ThermStats/issues/4#issuecomment-504745174

rasenior commented 4 years ago

Hi @washfaq. I've opened this as a new issue because it's not related to your previous issue about installing the package.

Apologies for the delay, but I haven't been able to replicate your error. Using the images you sent me, the code below works fine.

library(ThermStats)
# Extract
raw <- batch_extract(in_dir = "data_waseem")
# Convert (using default values for other parameters)
conv <- 
    batch_convert(raw_dat = raw$raw_dat, 
                  PR1 = raw$camera_params$PlanckR1,
                  PB = raw$camera_params$PlanckB,
                  PF = raw$camera_params$PlanckF,
                  PO = raw$camera_params$PlanckO,
                  PR2 = raw$camera_params$PlanckR2)

# Get just mean, min and max 
get_stats(img = conv$`1237`,
          id = "1237",
          calc_connectivity = FALSE,
          patches = FALSE,
          img_proj = NULL,
          img_extent = NULL,
          return_vals = "pstats",
          sum_stats = c("mean", "min","max"))

# Works fine, how about with patches as well?
get_stats(img = conv$`1237`,
          id = "1237",
          calc_connectivity = FALSE,
          patches = TRUE,
          style = "C",
          img_proj = NULL,
          img_extent = NULL,
          return_vals = "pstats",
          sum_stats = c("mean", "min","max"))

Running get_stats with patches=TRUE for just one image (1237) gives me no errors (though it is very slow). For the mean, min and mix I get 27.84133 22.15587 34.75978.

Are you able to provide a minimum working example that demonstrates your error?