Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
It is the same thing with pyshp, except that you cannot update directly the dbf file. When you read a shapefile, the data are stored in Python lists | |
import shapefile | |
input = shapefile.Reader("yourfile.shp") | |
shapes = input.shapes() # -> the geometries in a list | |
fields = input.fields[1:] -> the fields definition in a list | |
fields_name = = [field[0] for field in fields] -> the fields names in a list | |
attributes = input.records() -> the attributes in a list |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
'''For QGIS 2.8 | |
Martin Laloux, 2012''' | |
from PyQt4.QtCore import * | |
from numpy import * | |
class distance(object): | |
def __init__(self,a,angle,distance): | |
self.a = a.asPoint() | |
self.xori = self.a[0] |
'''QGIS master with the new Python API | |
Martin Laloux 2013''' | |
from PyQt4.QtCore import * | |
from numpy import * | |
from PyQt4.QtCore import * | |
from numpy import * | |
a = QgsGeometry.fromPoint(QgsPoint(122.989235,13679.083853)) |