如何用osmium export导出含route=bicycle的OSM关系数据?
用Osmium Export导出route=bicycle关系的方法
Osmium Export默认只处理几何定义明确的关系(比如route=ferry、type=multipolygon这类),route=bicycle这类由多个way组成的路线关系需要显式配置才能导出,具体操作如下:
- 必须添加
--include-relations参数,让工具处理关系数据; - 通过
--relation-types=route指定要处理路线类关系,再用--where过滤出自行车路线; - 工具会自动将关系包含的多个way合并为完整的线几何输出。
示例命令:
osmium export osm.pbf -o bicycle_routes.geojson --include-relations --relation-types=route --where "route='bicycle'"
如果需要导出所有类型的route关系,去掉--where过滤即可:
osmium export osm.pbf -o all_routes.geojson --include-relations --relation-types=route
旧版本兼容说明
如果你的Osmium版本没有--relation-types参数,可改用--keep-relations参数配合过滤:
osmium export osm.pbf -o bicycle_routes.geojson --keep-relations --where "route='bicycle'"
注意:要确保输入的osm.pbf包含route=bicycle关系的所有成员way,否则工具无法构建完整的几何线段。
内容的提问来源于stack exchange,提问作者hb0
相关产品推荐
相关产品推荐

