Error: Number of rows and columns must be a multiple of 2.
Closed this issue · 3 comments
Thanks for the excellent package and documentation. Quick question: is it possible to account for cases where method = 'aggregation'
and raster dimensions are not multiples of 2? If not, do you have a suggested adjustment so that arbitrary rasters can be used, even if that means a little "haircut"?
library(raster)
library(belg)
# fake data
x <- raster(nrows = 6, ncols = 7)
x[] <- rnorm(n = ncell(x), mean = 0, sd = 1)
# this works
get_boltzmann(x, method = 'hierarchy')
# this does not
get_boltzmann(x, method = 'aggregation')
Hi Dylan,
thanks for the questions. Long story short, there are two main methods implemented in belg: (1) hierarchy-based and (2) aggregation-based. Both of these methods have two variants: relative (calculation are based only on one scale) and absolute (the result is based on calculations of many spatial scales).
The first method was created in 2017 (https://link.springer.com/article/10.1007%2Fs10980-017-0515-x), however, in 2019, it was discovered that the absolute hierarchy-based method is not consistent. In other words, it can give wrong results for some corner cases (more about this can be found in https://link.springer.com/article/10.1007/s10980-019-00854-3). Therefore, a new approach (the aggregation-based method) was developed. However, it has a different limitation - it requires the number of rows and columns to be a multiple of 2.
Quick summary:
method | type | consistent | limitations |
---|---|---|---|
Hierarchy-based | Relative | Yes | |
Hierarchy-based | Absolute | No | |
Aggregation-based | Relative | Yes | rows and columns must be a multiple of 2 |
Aggregation-based | Absolute | Yes | rows and columns must be a multiple of 2 |
A started testing these ideas several months ago but dropped it due to limited time and other projects. I derived 619 different rasters (64 by 64 pixels) and calculated Boltzmann entropy using all four variants. You can find the correlation matrix of the results below:
These results suggest (in my opinion) that: (A) if you can - use the absolute aggregation-based method, (B) however, if you cannot (due to other raster dimensions), use the relative hierarchy-based method. Of course, the above results are not any closing evidence...
Let me know if you have any interest in this topic. If so, I can spend one afternoon cleaning my preliminary results and publishing them somewhere on the web.
Closing for now. @dylanbeaudette feel free to reopen this issue anytime!
Thanks! I'd like to come back to this topic soon, and I know that @pierreroudier will be interested as well.