<legend id='up7w3'><style id='up7w3'><dir id='up7w3'><q id='up7w3'></q></dir></style></legend>
<tfoot id='up7w3'></tfoot>
<i id='up7w3'><tr id='up7w3'><dt id='up7w3'><q id='up7w3'><span id='up7w3'><b id='up7w3'><form id='up7w3'><ins id='up7w3'></ins><ul id='up7w3'></ul><sub id='up7w3'></sub></form><legend id='up7w3'></legend><bdo id='up7w3'><pre id='up7w3'><center id='up7w3'></center></pre></bdo></b><th id='up7w3'></th></span></q></dt></tr></i><div id='up7w3'><tfoot id='up7w3'></tfoot><dl id='up7w3'><fieldset id='up7w3'></fieldset></dl></div>

    1. <small id='up7w3'></small><noframes id='up7w3'>

        <bdo id='up7w3'></bdo><ul id='up7w3'></ul>

      1. 绘制 OpenStreetMap 关系不会生成连续线

        时间:2023-08-06
        <tfoot id='hSYDh'></tfoot>
      2. <small id='hSYDh'></small><noframes id='hSYDh'>

        <legend id='hSYDh'><style id='hSYDh'><dir id='hSYDh'><q id='hSYDh'></q></dir></style></legend>

          • <i id='hSYDh'><tr id='hSYDh'><dt id='hSYDh'><q id='hSYDh'><span id='hSYDh'><b id='hSYDh'><form id='hSYDh'><ins id='hSYDh'></ins><ul id='hSYDh'></ul><sub id='hSYDh'></sub></form><legend id='hSYDh'></legend><bdo id='hSYDh'><pre id='hSYDh'><center id='hSYDh'></center></pre></bdo></b><th id='hSYDh'></th></span></q></dt></tr></i><div id='hSYDh'><tfoot id='hSYDh'></tfoot><dl id='hSYDh'><fieldset id='hSYDh'></fieldset></dl></div>

                  <tbody id='hSYDh'></tbody>
                  <bdo id='hSYDh'></bdo><ul id='hSYDh'></ul>
                  本文介绍了绘制 OpenStreetMap 关系不会生成连续线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  全部,

                  我一直致力于编制全球所有 MTB 路线的索引.我是 Python 人,所以对于涉及的所有步骤,我都尝试使用 Python 模块.

                  我能够像这样从 OSM overpass API 获取关系:

                  from OSMPythonTools.overpass import Overpass天桥=天桥()def fetch_relation_coords(关系):rel = overpass.query('rel(%s); (._;>); out;' % 关系)返回 relrel = fetch_relation_coords(6750628")

                  我选择这个特定的关系 (6750628),因为它是导致不连续(或其他错误)图的几个关系之一.

                  我处理rel"对象来获取这样的 pandas.DataFrame:

                  elements = pd.DataFrame(rel.toJSON()['elements'])

                  元素"看起来像这样:

                  Elements pandas.DataFrame 包含关系"类型的行.(在这种情况下为 1),有几种方式"类型.和许多类型的节点".我的理解是我会使用关系".行,成员"列提取方式的顺序(指向节点),并使用该顺序以正确的顺序制作节点的纬度和经度列表(供以后在传单中使用),即顺序这会导致地图上的连续路径.

                  然而,事实并非如此.对于这种特殊的关系,我最终得到了以下情节:

                  如果我们将其与

                  在数据库中,我宁愿对节点进行排序,因为我可以使用它们即时制作 GPX 文件.但我想我确实用这种方法回答了我自己的问题,感谢@scai 将我引向这个方向.

                  All,

                  I have been working on an index of all MTB trails worldwide. I'm a Python person so for all steps involved I try to use Python modules.

                  I was able to grab relations from the OSM overpass API like this:

                  from OSMPythonTools.overpass import Overpass
                  overpass = Overpass()
                  
                  def fetch_relation_coords(relation): 
                      rel = overpass.query('rel(%s); (._;>;); out;' % relation)
                      return rel
                  
                  rel = fetch_relation_coords("6750628")
                  

                  I'm choosing this particular relation (6750628) because it is one of several that is resulting in discontinuous (or otherwise erroneous) plots.

                  I process the "rel" object to get a pandas.DataFrame like this:

                  elements = pd.DataFrame(rel.toJSON()['elements'])
                  

                  "elements" looks like this:

                  The Elements pandas.DataFrame contains rows of the types "relation" (1 in this case), several of the type "way" and many of the type "node". It was my understanding that I would use the "relation" row, "members" column to extract the order of the ways (which point to the nodes), and use that order to make a list of the latitudes and longitudes of the nodes (for later use in leaflet), in the correct order, that is, the order that leads to continuous path on a map.

                  However, that is not the case. For this particular relation, I end up with the following plot:

                  If we compare that with the way the relation is displayed on openstreetmap.org itself, we see that it goes wrong (focus on the middle, eastern part of the trail). I have many examples of this happening, although there are also a lot of relations that do display correctly.

                  So I was wondering, what am I missing? Are there nodes with tags that need to be ignored? I already tried several things, including leaving out nodes with any tags, this does not help. Somewhere my processing is wrong but I don't understand where.

                  解决方案

                  If I opt to just plot the different way on top of each other, I indeed get a continuous plot (index contains the indexes for all nodes per way):

                  In the Database I would have preferred to have the nodes sorted anyway because I could use them to make a GPX file on the fly. But I guess I did answer my own question with this approach, thank you @scai for tipping me into this direction.

                  这篇关于绘制 OpenStreetMap 关系不会生成连续线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:R传单地图上的叠加图像 下一篇:如何确保 README.rst 有效?

                  相关文章

                  最新文章

                  1. <i id='PZFd9'><tr id='PZFd9'><dt id='PZFd9'><q id='PZFd9'><span id='PZFd9'><b id='PZFd9'><form id='PZFd9'><ins id='PZFd9'></ins><ul id='PZFd9'></ul><sub id='PZFd9'></sub></form><legend id='PZFd9'></legend><bdo id='PZFd9'><pre id='PZFd9'><center id='PZFd9'></center></pre></bdo></b><th id='PZFd9'></th></span></q></dt></tr></i><div id='PZFd9'><tfoot id='PZFd9'></tfoot><dl id='PZFd9'><fieldset id='PZFd9'></fieldset></dl></div>

                    <small id='PZFd9'></small><noframes id='PZFd9'>

                    1. <legend id='PZFd9'><style id='PZFd9'><dir id='PZFd9'><q id='PZFd9'></q></dir></style></legend>

                      • <bdo id='PZFd9'></bdo><ul id='PZFd9'></ul>
                      <tfoot id='PZFd9'></tfoot>