def load_nodes(self, nodes_file, id_field):
# Now we load the layer as geographic objects for the actual analysis
source = fiona.open(nodes_file, 'r')
azims = []
dirs = []
ids = []
self.nodes = []
print 'Creating nodes spatial index'
for feature in source:
geom = shape(feature['geometry'])
i_d = int(feature["properties"][id_field])
self.idx_nodes.insert(i_d, geom.bounds)
x, y = geom.centroid.coords.xy
self.nodes.append([i_d, float(x[0]), float(y[0])])
self.nodes = pd.DataFrame(self.nodes, columns = ['ID', 'X', 'Y']).set_index(['ID'])
print ' NODES spatial index created successfully'
评论列表
文章目录