添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

经典的利用轨迹生成地图的算法与数据集可寻找于: Mapconstruction by pfoser

Mapconstruction by pfoser 数据集中,雅典数据集投影坐标系为(UTM, GGRS87),EPSG为2100,芝加哥数据集投影坐标系为(NAD83 / UTM zone 16N),EPSG为26916,柏林数据集投影坐标系为(ETRS89 / UTM zone 33N),EPSG为25833

此处笔者介绍 Ahmed Karagiorgou Biagioni 的算法

1. Ahmed算法

此算法基于增量合并的方式,不断加入新的轨迹进行匹配,得到新的路网

代码可下载自: GitHub - pfoser/mapconstruction: Map Construction Algorithms

代码基于Java构建和shell脚本,最好是在安装有Java环境的Linux或者Mac平台上运行

切换到 Ahmed 目录下,编辑 script_to_run.sh 文件:

#To Compile:
CODE_PATH="MapConstruction/" #path to the MapConstruction folder.
cd $CODE_PATH
javac -d bin/ src/mapconstruction2/*.java
#To Run:
INPUT_PATH="" #path to the folder that constains all input tracks
OUTPUT_PATH="" #path to the folder where output will be written
EPS=150.0 #epsilon in meters
HAS_ALTITUDE=false #if input file has altitude information
ALT_EPS=4.0 #minimum altitude difference in meters between two streets
java -cp bin/ mapconstruction2.MapConstruction $INPUT_PATH $OUTPUT_PATH $EPS $HAS_ALTITUDE $ALT_EPS

设置好路径与参数,运行script_to_run.sh脚本,等待程序结束

2. Karagiorgou算法

此算法基于交叉口连接,找出道路中的交叉口进行连接,得到路网

代码可下载自:GitHub - pfoser/mapconstruction: Map Construction Algorithms

代码基于Matlab构建

代码运行步骤在代码的README.txt中已经详细说明

1) Add the two directories /source and /libraries to the current working path of the MATLAB
2) The source code is in the /source directory
3) The trajectory files should be in the form of: <x y timestamp>
4) You should firstly run the intersection_nodes_extraction.m file
   This file loads trajectories and generates intersection nodes
5) You should then run the tracebundle.m file
   This file loads trajectories and intersection nodes and generates road network vertices and edges.
   It generates two files tracebundle_vertices.txt, tracebundle_edges.txt.

路网可视化

AhmedKaragiorgou算法生成的都是节点文件与边的文件,这里笔者提供一个转化为GeoJSON从而可视化的代码片段

vertices_dict = {}
with open('./data/resultvertices.txt','r') as vertices:
    for line in vertices:
        tmp = line.split(',')
        vertices_dict[int(tmp[0])] = [float(tmp[1]),float(tmp[2][:-1])]
edge_arr = []
with open('./data/resultedges.txt','r') as edges:
    for line in edges:
        tmp = line.split(',')
        edge_arr.append([vertices_dict[int(tmp[1])],vertices_dict[int(tmp[2])]])
import os
import json
def save_trajs(data, path, type_style):
    res = {
        "type": "FeatureCollection",
        "features": []
    for i, traj in enumerate(data):
        t = {
            "type": "Feature",
            "geometry": {
                "type": "LineString", "coordinates": traj
            "properties": {
                "id": i
        res["features"].append(t)
    if os.path.exists(path):
        os.remove(path)
    with open(path, "w") as f:
        if type_style == "LineString":
            json.dump(res, f)
save_trajs(edge_arr, "./final_map.json", "LineString")

生成的GeoJSON文件可直接拖入QGIS软件进行可视化

3. Biagioni算法

此算法基于KDE,利用核密度估计图像生成路网

代码和数据下载地址:Bits - Software (uic.edu)

代码基于Python 2 构建

环境搭建过程可见:Map Inference in the Face of Noise and Disparity代码环境搭建 - 当时明月在曾照彩云归 - 博客园 (cnblogs.com)