network.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:map_matching 作者: pedrocamargo 项目源码 文件源码
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'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号