简体   繁体   English

如何使用 Python 和立交桥 API 从 OpenStreetMap 下载非洲的所有医院?

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

I need a shapefile of every hospital in continental Africa from OSM.我需要 OSM 提供的非洲大陆每家医院的 shapefile。 At this point, I've only played with downloading extracts from other services like geofabrik, I haven't actually pulled any data down myself.在这一点上,我只玩过从 geofabrik 等其他服务下载提取物,实际上我自己并没有提取任何数据。 While I intend on learning how to use the Overpass API, I need a quick turnaround for this project.虽然我打算学习如何使用立交桥 API,但我需要快速完成这个项目。 How can I use Python and the Overpass API to download a dataset of Africa's hospitals?如何使用 Python 和立交桥 API 下载非洲医院的数据集?

A spectacularly quick and short crash course:一个惊人的快速和简短的速成课程:

The example below uses Congo only because it's smaller than all of Africa, and you may need to also add eg healthcare=* as a filter:下面的示例仅使用刚果,因为它比整个非洲都小,您可能还需要添加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.
$

As you can see from the warnings and errors, shapefiles are slightly legacy;从警告和错误中可以看出,shapefile 有点遗留; if GeoPackages are an option,如果 GeoPackages 是一个选项,

$ ogr2ogr -f GPKG congolese-hospitals.gpkg ./congolese-hospitals.osm.pbf
0...10...20...30...40...50...60...70...80...90...100 - done.

For proof, here's a part of the result being browsed in JOSM:为了证明,这是在 JOSM 中浏览的部分结果:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试使用Python请求将xml文件发送到OpenStreetMap Overpass API - Trying to send xml file using Python Requests to OpenStreetMap Overpass API 从OpenStreetMap Overpass API输出中提取ID(字典中的Python列表) - Extract ids from OpenStreetMap Overpass API output (python list in dictionary) 如何使用Python的立交桥API从开放街道地图中获取所有电厂? - How to get all power plants from Open Street Map using overpass api with python? 无法通过Python使用Overpass API打印查询 - Failing to print query using Overpass API with Python 如何使用 Python 从 Kaggle 下载 notebook? - How can I download notebook from Kaggle Using Python? 使用 ArcGIS Python API,如何与公众共享 ArcGIS Online 中特定组中的所有项目? - Using ArcGIS Python API, how can I share all items in a specific group from ArcGIS online with the public? python osmnx - 如何根据边界 ID 从 OpenStreetMap 下载市区 map? - python osmnx - How to download a city district map from OpenStreetMap based on the boundary ID? 如何使用 python 客户端 api 从 GCS 云存储桶下载文件夹中的所有文件? - How to download all files in a folder from GCS cloud bucket using python client api? Python 请求,下载 Overpass Turbo XML - Python Requests, download Overpass Turbo XML 如何在 OpenStreetMap 上获得最短路径? - How can I get a shortest path on OpenStreetMap?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM