作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在寻找一种从 OpenStreetMap (OSM) 数据中准确检索街道交叉口的方法。我知道有人提出并回答了类似的问题,但我可以从建议的方法中检索到的数据不是很准确。
首先,我知道以下问题:
"Query all ways in a given bounding box and look for nodes shared by two or more ways as explained in the other answer."
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
38.8966440,-77.0259810
38.8973430,-77.0280900
38.9010391,-77.0270309
38.8961050,-77.0319620
...
最佳答案
第一个提示:
不仅要与谷歌地图进行比较,还要将您的坐标主要与 OpenStreetMap 可视化进行比较。尤其是复杂的街道交叉口,虽然它们代表相同的道路,但可以进行不同的建模。
2):看看你是否真的使用了正确的方式:那是人行道,与街道混合吗?有各种不同的类型,具有不同的属性:车辆可通行等。在谷歌地图中,白色道路是车辆可通行的道路
3)进一步看,如果你没有混合房屋多边形。
关于openstreetmap - 如何从 OpenStreetMap 数据中找到街道交叉口的列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14716497/
我是一名优秀的程序员,十分优秀!