def calcWeightMatrix(self, get_wm=0): wm = None if self.geotype == 'Polygon': parser = WKTParser() shape_l = MyList([parser.fromWKT(s) for s in self.listWKT]) neighbour_data = ContiguityWeights(shape_l).w wm = WeightMatrix(neighbour_data, id_order=self.ids) elif self.geotype == 'Point': parser = WKTParser() shape_l = MyList([parser.fromWKT(s) for s in self.listWKT]) #wm = pysal.knnW_from_array(np.array(self.listWKT), k=5, ids=self.ids) wm = pysal.knnW_from_array(np.array(shape_l), k=5, ids=self.ids) if get_wm == 1: return wm warray = self.dict2array(wm, self.N) return warray
def __open(self): self.dataObj = open(self.dataPath, self.mode) self.wkt = WKTParser()