This week work on spatial weights for flow data began. So far it has resulted in three new functions. The first two functions refer to two different types of the weights while the third is a helper function.
The two types of weights are origin-destination spatial contiguity weights which denote two flows to be neighbors if their origins or their destinations are spatially contiguous. The first type of weight is created by the function ODW() takes as input an O X O W object denoting origin spatial contiguity and a D x D W object denoting destination contiguity and then returns the O*D x O*D origin-destination W object where O = # of origins and D = # of destinations. The second weight, network-based weights, interprets assocations among flows to mean that they share nodes an abstract network representation of the flow system. To this end, two flows may be neighbors is they share any single node, if they share an origin node, if they share a destination node, or if they share an origin or a destination node. Each scenario produces somewhat different spatial weights capturing slightly different notions of associations. This function, netW(), takes as input a list of tuples, (origin,destination) that represent the edges of a network, as well as a parameter to denote which type of nodal association to use, and returns an O*D x O*D W object.
Finally, the third function was designed to convert a matrix or array that denotes flows or network edges into a list of tuples to be used as input to the netW() function described above.
Still to come is a distance-based weight that uses all four dimenions avialalbe when comparing two flows (origin 1, destination 1, origin 2, destination 2).