簡體   English   中英

如何使用 Python 和立交橋 API 從 OpenStreetMap 下載非洲的所有醫院?

[英]How can I download all hospitals in Africa from OpenStreetMap using Python and the Overpass API?

我需要 OSM 提供的非洲大陸每家醫院的 shapefile。 在這一點上,我只玩過從 geofabrik 等其他服務下載提取物,實際上我自己並沒有提取任何數據。 雖然我打算學習如何使用立交橋 API,但我需要快速完成這個項目。 如何使用 Python 和立交橋 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 有點遺留; 如果 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.

 
粵ICP備18138465號  © 2020-2025 STACKOOM.COM