예제 #1
0
파일: map.py 프로젝트: GaminiKumara/eden
 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
예제 #2
0
 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
예제 #3
0
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
예제 #4
0
파일: shp.py 프로젝트: Akanksha18/eden
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