Skip to content
Sergio Rey edited this page Feb 10, 2016 · 9 revisions

Abstraction of W Construction

Motivation

Currently we are writing specific handlers for each new type of weight input we want to support. The logic here is that the handler has to get to the point were the neighbor dictionary and associated weight dictionary are constructed from the data in the input file.

This works, but it seems brittle. We may want to refactor this so that we have each input type construct a common intermediate format that is internal. This internal format is then used to construct the specific type of weights.

There are two cases to consider here. In the first, the input file already contains information about contiguity or weights and we simply open, read, and construct a PySAL W. An example would be a gal or winbugs input file. These are already covered.

The second case is for files that do not have information on the weights, but rather we need to construct the weights from the data in the file. For example a shapefile, a point file, or a json file. Here is where the refactoring should focus as the contiguity, or distance, builders should be generic and take an internal data structure so that we only have to write it once. The handlers would take the particular input type and convert to this internal format from which the builder would derive the desired weights.

We should support the following cases

  • local files
  • uri
  • iterators (as in qgis processing)

And, we should keep in mind that everything is a file.

Targets

The following are tightly coupled to shapefiles

Need to generalize these and add Jay's optimizations along the way.

Public Branch and Related Code

Work on this is being performed in the following branch: wconstructor

There is also work with QGIS folk to explore PySAL integration. For vector layers, QGIS has a nice framework for mapping different provider types to a common layer. Work exploring this for contiguity builder is here and can serve as a basis for the integration as well as ideas for how to interact with other systems/providers outside of QGIS.

Resources