def load(self): shapes = shapelib.open(self.name) if len(self._fields) != 0: data = dbflib.open(self.name) list = SpatialPointList() for i in range(shapes.info()[0]): records = Dictionary() for key, gen in self._fields: records.update([(gen, float(data.read_record(i)[key]))]) x = float(shapes.read_object(i).vertices()[0][0]) y = float(shapes.read_object(i).vertices()[0][1]) list.append(SpatialPoint(x, y, records, self)) return list
def pointsFromSHP(pointsFilename, datafield=[]): shapes = shapelib.open(pointsFilename) if len(datafield) != 0: data = dbflib.open(pointsFilename) list = SpatialPointList() for i in range(shapes.info()[0]): records = {} pair = [] for entry in datafield: pair.append((entry, data.read_record(i)[entry])) records.update(pair) x = shapes.read_object(i).vertices()[0][0] y = shapes.read_object(i).vertices()[0][1] list.append(SpatialPoint(x, y, records)) return list
def pointsFromSHP (pointsFilename, datafield=[]): shapes = shapelib.open(pointsFilename) if len(datafield) != 0: data = dbflib.open (pointsFilename) list = SpatialPointList () for i in range (shapes.info ()[0]): records = {} pair = [] for entry in datafield: pair.append ((entry, data.read_record (i)[entry])) records.update (pair) x = shapes.read_object (i).vertices ()[0][0] y = shapes.read_object (i).vertices ()[0][1] list.append (SpatialPoint (x, y, records)) return list