首页 > 解决方案 > 如何使用 OSMOSIS 提取多面数据

问题描述

要更新我的数据库,我需要从 OSM 数据库中提取一些数据。为此,我从 GEOFABRIK 网站下载了 osm pbf 文件。我希望从这个 PBF 文件中提取所有具有一些关键值的多边形和多多边形。我的问题是我在 osmosis 中使用的任何命令行,似乎我错过了 multipolygon 类型的对象。为了说明我的问题,您将在关键字 amenity 中找到我用于带有标签 townhall 的对象的命令。

为此,我尝试了一些命令:

osmosis --read-xml nord-pas-de-calais-latest.osm --way-key-value keyValueList="amenity.townhall" --bounding-box top=50.794448377057 left=2.78824307841151 bottom=50.4995835747462 right=3.2719212468744 --used-node  --write-xml #target_file.osm#

或者

osmosis --read-pbf nord-pas-de-calais-latest.osm.pbf --log-progress --tf accept-ways amenity=townhall --bounding-box top=50.794448377057 left=2.78824307841151 bottom=50.4995835747462 right=3.2719212468744 --used-node --write-xml extraction_test_townhall.osm

和那些命令行

# read all nodes with amenity=townhall or townhall=yes, ignore ways and relations
osmosis --read-xml nord-pas-de-calais-latest.osm --tf accept-nodes amenity=townhall --tf reject-ways --tf reject-relations --write-xml amenity_townhall_nodes.osm

osmosis --read-xml nord-pas-de-calais-latest.osm --tf accept-nodes townhall=yes     --tf reject-ways --tf reject-relations --write-xml townhall_yes_nodes.osm

# read all ways with amenity=townhall or townhall=yes, keep only related nodes, ignore relations
osmosis --read-xml nord-pas-de-calais-latest.osm --tf accept-ways  amenity=townhall --used-node --tf reject-relations --write-xml amenity_townhall_ways.osm

osmosis --read-xml nord-pas-de-calais-latest.osm --tf accept-ways  townhall=yes     --used-node --tf reject-relations --write-xml townhall_yes_ways.osm

# read all relations with amenity=townhall or townhall=yes, keep only related ways and nodes
osmosis --read-xml nord-pas-de-calais-latest.osm
--tf accept-relations amenity=townhall --used-way --tf accept-relations townhall=yes --used-node --write-xml amenity_townhall_relations.osm

osmosis --read-xml nord-pas-de-calais-latest.osm --tf accept-relations townhall=yes --used-way --tf accept-relations townhall=yes --used-node --write-xml townhall_yes_relations.osm

# merge all files together
osmosis --rx amenity_townhall_nodes.osm --rx townhall_yes_nodes.osm --rx amenity_townhall_ways.osm --rx C:\Users\rjault\Documents\02_DEMANDE\13_OSM_ORACLE\OSMOSIS\townhall_yes_ways.osm --rx amenity_townhall_relations.osm --rx townhall_yes_relations.osm --merge --merge --merge --merge --merge --wx townhall.osm

我使用哪个命令都没有关系,结果总是一样的。你可以在图片上看到,绿色是原始数据集,紫色是我提取的市政厅。例如,以红色包围的对象在我的提取中丢失。

在此处输入图像描述

我也尝试过 AKX 带来的解决方案,但即使在那里,我仍然想念我所在地区最大的市政厅。OSM 似乎是一个非常好的数据库,我希望更多地使用它。

所以谢谢你的帮助。

标签: extractpolygonopenstreetmaposmosis

解决方案


这有所帮助,但它保留了一组包含道路和建筑数据的选定点。

osmosis --rx file="input file" --tf accept-ways building=* geometry-type=multipolygon --wx "output file"

推荐阅读