看不太懂,但感觉有用的东西。Openstreetmap 是什么?
-
用来入门(或者说先知道这是什么)简单的百度百科介绍
-
这个链接展示了如何下载一定格式的地图(shp、osm格式)。
OpenStreetMap开源地图数据下载方法(含shp格式) -
那问题来了,shp和osm格式都是什么东西呀?
-
用python解读osm数据:
- 先熟悉python的各个接口
osmium.osm.Node class示例:

osmium.osm.Way 示例:

In Osmium, ways can optionally also have a location for each node
reference. This will usually be empty but can be filled, for instance
using the NodeLocationsForWays handler (see below). This is very
convenient for many use cases.
看起来从way的WayNodeList找到的node 不太对,记录reference,再查下。直接拿会错。
目前只能通过ref,再次寻找地图点来确定位置。git源码就是这么做的。
但如果用了
h.apply_file("test.osm.pbf", locations=True, idx='dense_file_array,example.nodecache')
则也许location里是有内容的,待验证。
验证成功可以用。
osmium.osm.Relation 示例:

从官方文档看到了(https://github.com/osmcode/pyosmium/blob/master/examples/road_length.py):
self.length += o.geom.haversine_distance(w.nodes)
说明在地图领域,或者高精地图领域,还是有一些函数的,只是才入门,不太懂而已。问题是确实相关材料不多。
- 然后看osmium的各个定义,进行继续开发,后者接其他库,进行图像操作。
从git上看有用的代码:
| 代码 |
|---|
| https://github.com/osmcode/pyosmium/blob/master/examples/amenity_list.py |
| https://github.com/osmcode/pyosmium/blob/master/examples/convert.py |
| https://github.com/osmcode/pyosmium/blob/master/examples/filter_coastlines.py |
| https://github.com/osmcode/pyosmium/blob/master/examples/normalize_boolean.py |
| https://github.com/osmcode/pyosmium/blob/master/examples/osm_file_stats.py |
| https://github.com/osmcode/pyosmium/blob/master/examples/pub_names.py |
| https://github.com/osmcode/pyosmium/blob/master/examples/road_length.py |
| https://github.com/osmcode/pyosmium/blob/master/examples/road_length.py |
本文介绍了OpenStreetMap(OSM)的基本概念,并提供了下载OSM和shp格式地图的方法。OSM是一种开源地图数据,而shp和osm是两种常见的数据格式。文章深入探讨了如何使用Python解析和处理OSM数据,包括Node、Way和Relation的使用,以及利用osmium库进行地图数据的读取和分析。还给出了多个osmium库的示例代码链接,用于进一步的开发和学习。此外,提到了官方文档和一些实用工具,如h.apply_file(),用于获取WayNodeList中Node的位置信息。文章适合对地图数据处理感兴趣的读者。
6369

被折叠的 条评论
为什么被折叠?



