Open MgeeeeK opened 4 years ago
@darribas @slumnitz
One potential idea that was floated in the meeting was to first implement DistanceBand functionality and then map higher_order operation to the DistanceBand.
Can you elaborate on this? In my eyes, these two are based on different concepts. DistanceBand
captures geographical position of elements, while higher_order
topological. I am trying to understand how do you envisage one to be used within another.
I wasn't part of the meeting, but in my experience, using higher_order
adapted to k<=n
instead of k==n
as mentioned in #313 works very well if you need larger neighbourhood and may work equally well for raster data. We just need an efficient algorithm for that (both computationally and memory efficient - the one proposed in the issue may eat a lot of ram for higher k
).
The suggestion in the meeting was that inclusive higher-order Rook/Queen weights are equivalent to distance-band weights for a given radius. We might be able to make that fast using a query_ball_tree
strategy for individual sites on demand.
It was only a suggestion for exploration if performance issues persisted with a performant sparse adjacency matrix-based algo.
Although, now thinking about it, Distance Bands are not reducible to higher-order rook/queen in the case of nulls:
- - - + - - - -
- - + + + - - -
. . + + + + - -
o . . X + + + -
- o . . + + - -
- - o . . - - -
- - - o . . - -
In the simple schematic above, X
is the focal pixel, .
are missing values, +
are the true third-order (and below) Rook neighbors, and o
are erroneously included in this set using a distance band strategy (if we assume that masked values are barriers, which I think is the intent?)
Following along libpysal/#293 and weights object meeting, this issue documents the discussion for the addition of
DistanceBand
functionality inside raster interface.Background
KNN
converts cell centroids into points and then ship directly intoKNN
builder) but this would not resolve the ties issue particularly for rasters.higher_order
, but right now it removes lower order contiguities (which is also raised here libpysal/#313)Potential Solution
DistanceBand
can be a good alternative approach for obtaining larger neighbors of each cell.DistanceBand
functionality and then maphigher_order
operation to theDistanceBand
.