def __init__(self, segments, nbins=500): self.data = segments if hasattr(segments, 'bounding_box'): bbox = segment.bounding_box else: bbox = get_bounding_box(segments) self.bbox = bbox res = max((bbox.right - bbox.left), (bbox.upper - bbox.lower)) / float(nbins) self.grid = SegmentGrid(bbox, res) for i, seg in enumerate(segments): self.grid.add(seg, i)
def __init__(self, collection, wttype=1, bbox=None): """ Parameters ========== collection: PySAL PolygonCollection wttype: int 1: Queen 2: Rook """ self.collection = collection self.wttype = wttype if bbox is None: try: bbox = collection.bbox except AttributeError: bbox = get_bounding_box(collection) self.shapebox = bbox self.numPoly = len(collection) self.do_weights()