pysal / libpysal

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

Idea collection/discussion for Raster awareness project #293

Open MgeeeeK opened 4 years ago

MgeeeeK commented 4 years ago

This issue sheds some light on the discussions I'd during raster awareness.. project calls. Some of the main points discussed are listed below:

Discussion also involved brainstorming for features and functionality to be incorporated after phase 1:

This issue will also be used for future discussion related raster awareness project and is open for discussion!, any suggestions or feedbacks are most welcome.

darribas commented 4 years ago

Great start!

A couple more bits from the discussions we've had:

darribas commented 4 years ago

A quick post to elaborate on the optimization phase, once we have the API ironed out. My suspicion is the main area to improve will be building weights efficiently. Efficiently in this context means scalable (using as little memory as possible) and fast. Here're two steps to take:

@MgeeeeK / @slumnitz does this sound sensible/feasible? If so, maybe we should move these parts into separate issues to track progress on them independently?

MgeeeeK commented 4 years ago

This sounds promising @darribas ... I have to figure out the logic for both methods raster2W/SW, after finalizing the interface's API this week and adding tests I'll look into the possible logic of creating weights object with only non-missing data from start which will be more efficient than current method. Side-by-side I can start working on incorporating numba to speed up existing methods.

darribas commented 4 years ago

More ideas for the optimisation phase:

martinfleis commented 4 years ago

@darribas just to clarify as I was dealing with it today in #313. higher_order does not make neigbors of neighbor also a neighbor, but makes them only neighbors. It ignores lower-order contiguities at the moment.

sjsrey commented 4 years ago

To add some background, the original implementation of higher_order follows from the logic in Anselin and Smirnov (1996).

ljwolf commented 4 years ago

Given our call the other day, I wanted to provide some background for the statements I was making about network representations. I knew they were stuck way deep down somewhere from my time early in my PhD when I was still pursuing the dual degree between Industrial Engineering & Geography. Ahuja, Magnati, & Ohrlin. Network Flows: Theory, Algorithms, & Applications, is a wonderful book on graph theory from an industrial engineering perspective. Chapter 2 has this discussion on network representations. Lots of it is quite outdated (e.g. performance of implementing these in C++/FORTRAN will be different for us) but conceptually, these are useful:

Screenshot from 2020-07-15 10-42-39

In their language:

Our neighbors, weights dict strategy approaches the singly-linked adjacency list from AMO, with a few key differences:

  1. our cells have a single value: the index of the neighbor. AMO suggests representing this (basically) as a C struct that contains all information about the edge.
  2. our indices have mixed semantics. For example, cannot assume neighbors[i][j] is reversible to neighbors[j][i], since nodes might have string-based names (so i can definitely be a string) but their ordinal position in neighbors[i] is integer-valued (so, j must be an int). That is, for neighbors[i][j], i is a node's "name" but j is the index of node j in i's neighbor list. To approximate this reversibility property in AMO's singly-linked list, we can just use j_name = neighbors[i_name][j_idx], if j_idx is known in advance. But, for real reversibility, we would need dict-of-dicts or some other index of how to map from j_index_in_i_neighbors to j_name.
  3. weights are separated from indices: if we delete neighbors[i_name][j_ix], the corresponding weight also has to be deleted in weights[i_name][j_idx]. in AMO, you delete the cell of the linked list & all information about that link is removed.
MgeeeeK commented 4 years ago

Thanks @ljwolf, this is really handy for me to get clear picture of W object.

darribas commented 4 years ago

@MgeeeeK I'd open a separate issue just to fully flesh out the new structure of WSP objects and track its implementation for GSoC'20