如何使用Python和OverpassAPI从OpenStreetMap下载非洲的所有医院?

如何使用Python和OverpassAPI从OpenStreetMap下载非洲的所有医院?,python,api,gis,openstreetmap,overpass-api,Python,Api,Gis,Openstreetmap,Overpass Api,我需要OSM提供的非洲大陆所有医院的档案。在这一点上,我只玩过从geofabrik等其他服务下载摘录,实际上我自己并没有下载任何数据。虽然我打算学习如何使用立交桥API,但我需要为这个项目快速周转。如何使用Python和Overpass API下载非洲医院的数据集?一个非常快速和简短的速成课程: 下载 使用 将过滤后的数据转换为具有 以下示例使用刚果只是因为它比整个非洲都小,您可能还需要添加例如healthcare=*作为过滤器: $ wget https://download.geofabri

我需要OSM提供的非洲大陆所有医院的档案。在这一点上,我只玩过从geofabrik等其他服务下载摘录,实际上我自己并没有下载任何数据。虽然我打算学习如何使用立交桥API,但我需要为这个项目快速周转。如何使用Python和Overpass API下载非洲医院的数据集?

一个非常快速和简短的速成课程:

下载 使用 将过滤后的数据转换为具有 以下示例使用刚果只是因为它比整个非洲都小,您可能还需要添加例如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有点过时;如果地理包是一种选择

$ ogr2ogr -f GPKG congolese-hospitals.gpkg ./congolese-hospitals.osm.pbf
0...10...20...30...40...50...60...70...80...90...100 - done.
为了证明这一点,以下是在JOSM中浏览的部分结果:


除了渗透作用,你也可以使用。它更快,可能更容易使用。@scai可能是,但渗透作用有很好的例子,锇工具很少,至少快速浏览一下。