7

OpenStreetMap(OSM)データから交差点を正確に取得する方法を探しています。同様の質問と回答があったことは承知していますが、提案された方法から取得できるデータはあまり正確ではありません。

まず第一に、私は次の質問を知っています:

前述の質問に対する回答は、次のことを示唆しています。

「特定のバウンディングボックスですべての方法を照会し、他の回答で説明されているように、2つ以上の方法で共有されているノードを探します。」

私はこの提案に従い、OpenStreetMapからダウンロードしたxmlファイル(osmファイル)からノード要素を抽出するPythonスクリプトを作成しました。コードは次のとおりです。

try:
    from xml.etree import cElementTree as ET
except ImportError, e:
    from xml.etree import ElementTree as ET

def extract_intersections(osm, verbose=True):
    # This function takes an osm file as an input. It then goes through each xml 
    # element and searches for nodes that are shared by two or more ways.
    # Parameter:
    # - osm: An xml file that contains OpenStreetMap's map information
    # - verbose: If true, print some outputs to terminal.
    # 
    # Ex) extract_intersections('WashingtonDC.osm')
    #
    tree = ET.parse(osm)
    root = tree.getroot()
    counter = {}
    for child in root:
        if child.tag == 'way':
            for item in child:
                if item.tag == 'nd':
                    nd_ref = item.attrib['ref']
                    if not nd_ref in counter:
                        counter[nd_ref] = 0
                    counter[nd_ref] += 1

    # Find nodes that are shared with more than one way, which
    # might correspond to intersections
    intersections = filter(lambda x: counter[x] > 1,  counter)

    # Extract intersection coordinates
    # You can plot the result using this url.
    # http://www.darrinward.com/lat-long/
    intersection_coordinates = []
    for child in root:
        if child.tag == 'node' and child.attrib['id'] in intersections:
            coordinate = child.attrib['lat'] + ',' + child.attrib['lon']
            if verbose:
                print coordinate
            intersection_coordinates.append(coordinate)

    return intersection_coordinates

OSMからエクスポートしたデータを使用してこのコードを実行すると(たとえば、エクスポート領域からエクスポートされたデータを使用した場合:最小緯度:38.89239、最大緯度:38.89981、最小経度:-77.03212、最大経度:-77.02119)、次のような座標を出力します。

38.8966440,-77.0259810
38.8973430,-77.0280900
38.9010391,-77.0270309
38.8961050,-77.0319620
...

これらの座標をGoogleマップにプロットすると、次のようになります。 ここに画像の説明を入力してください

(私はhttp://www.darrinward.com/lat-long/を使用してデータをプロットしました。)データには交差点ではないノードが含まれているようです(おそらく2つのスティートに面している店舗です)。

私は何か間違ったことをしているのですか、それともこれはOSMから取得できる最高の「交差」データですか?私はあなたの助けとコメントに感謝します。

一番、

4

1 に答える 1

5

最初のヒント:

Google マップと比較するだけでなく、座標を主に OpenStreetMap の視覚化と比較してください。特に複雑な交差点は、同じ道路を表していますが、異なるモデルにすることができます。

2): あなたが本当に正しい道を使っているかどうか見てください。さまざまな種類があり、さまざまな属性があります: 車でアクセス可能などです。Google マップでは、白い道が車でアクセスできる道路です。

3)家のポリゴンが混ざっていない場合は、さらに見てください。

于 2013-02-05T20:52:07.690 に答える