
[英]Trying to send xml file using Python Requests to OpenStreetMap Overpass API
[英]How can I download all hospitals in Africa from OpenStreetMap using Python and the Overpass API?
我需要 OSM 提供的非洲大陆每家医院的 shapefile。 在这一点上,我只玩过从 geofabrik 等其他服务下载提取物,实际上我自己并没有提取任何数据。 虽然我打算学习如何使用立交桥 API,但我需要快速完成这个项目。 如何使用 Python 和立交桥 API 下载非洲医院的数据集?
一个惊人的快速和简短的速成课程:
osmosis
过滤它以仅保留某些标签ogr2ogr
将过滤后的数据转换为 shapefile 下面的示例仅使用刚果,因为它比整个非洲都小,您可能还需要添加healthcare=*
作为过滤器:
$ wget https://download.geofabrik.de/africa/congo-democratic-republic-latest.osm.pbf
(Progress...)
$ osmosis --read-pbf congo-democratic-republic-latest.osm.pbf --log-progress --tf accept-ways amenity=hospital,clinic,doctors,dentist --used-node --write-pbf congolese-hospitals.osm.pbf
INFO: Osmosis Version 0.48.2
INFO: Preparing pipeline.
INFO: Launching pipeline execution.
INFO: Pipeline executing, waiting for completion.
INFO: Processing Node 2096625632, 419655.26894621074 objects/second.
INFO: Processing Node 6901615718, 515231.3074770092 objects/second.
INFO: Processing Way 661735764, 877193.7612477505 objects/second.
INFO: Processing completion steps.
INFO: Completion steps took 13.833 seconds.
INFO: Processing complete.
INFO: Pipeline complete.
INFO: Total execution time: 90156 milliseconds.
$ ogr2ogr -f "ESRI Shapefile" congolese-hospitals ./congolese-hospitals.osm.pbf
0...10...20...30...40...50...60...70...80...90...100 - done.
Warning 6: Normalized/laundered field name: 'admin_level' to 'admin_leve'
ERROR 6: Geometry type of `Geometry Collection' not supported in shapefiles. Type can be overridden with a layer creation option of SHPT=POINT/ARC/POLYGON/MULTIPOINT/POINTZ/ARCZ/POLYGONZ/MULTIPOINTZ/MULTIPATCH.
$
从警告和错误中可以看出,shapefile 有点遗留; 如果 GeoPackages 是一个选项,
$ ogr2ogr -f GPKG congolese-hospitals.gpkg ./congolese-hospitals.osm.pbf
0...10...20...30...40...50...60...70...80...90...100 - done.
为了证明,这是在 JOSM 中浏览的部分结果:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.