pysal / libpysal

Core components of Python Spatial Analysis Library
http://pysal.org/libpysal
Other
266 stars 78 forks source link

Distance Band functionality for Raster Interface #328

Open MgeeeeK opened 4 years ago

MgeeeeK commented 4 years ago

Following along libpysal/#293 and weights object meeting, this issue documents the discussion for the addition of DistanceBand functionality inside raster interface.

Background

Potential Solution

MgeeeeK commented 4 years ago

@darribas @slumnitz

martinfleis commented 4 years ago

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).

ljwolf commented 4 years ago

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.

ljwolf commented 4 years ago

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?)