看不太懂,但感觉有用的东西。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 |