2

I'm not really interested in generating tiles if I can help it. Instead, what I'm looking for is a means of getting "what is near me" kind of information, specifically bodies of water and green space, or even civil services.

If I had the map tiles, I suppose I could parse them for the colours I want, but I'm thinking that there must be a better/smarter way. Isn't is possible to get a list of objects near lat,lng that belong to categories A and B?

I'm a competent Python programmer, but am completely new to OSM. I understand that I can download a Very Large XML file and have all the data, but accessing it, especially for this sort of purpose is totally foreign to me.

I should however that I have at my disposal complete access to a PostgreSQL database complete with PostGIS in a GeoDjango setup.

4

2 回答 2

5

瓦片不是必需的,生成瓦片只是使用 OSM 数据的一种可能方式。

您需要在线或离线解决方案吗?对于在线解决方案,您甚至不需要数据的本地副本。相反,您可以直接获取特定位置周围的数据。不要使用主要用于编辑而不是批量查询的官方API ,只需使用速度更快且具有复杂查询语言的Overpass API

这是一个示例 Overpass API 查询,用于查询给定边界框50.6,7.0,50.65,7.05内的所有商店停车位

(
  node
    ["shop"]
    (50.6,7.0,50.65,7.05);
  node
    ["amenity"="parking"]
    (50.6,7.0,50.65,7.05);
  way
    ["shop"]
    (50.6,7.0,50.65,7.05);
  way
    ["amenity"="parking"]
    (50.6,7.0,50.65,7.05);
  relation
    ["shop"]
    (50.6,7.0,50.65,7.05);
  relation
    ["amenity"="parking"]
    (50.6,7.0,50.65,7.05);
);
(
  ._;
  >;
);
out;

(结果可以以XMLJSON格式下载。您也可以使用overpass turbo对其进行可视化)

为了理解查询,您必须熟悉OSM 的基本元素节点方式关系)以及标记系统最常见的标记

如果您需要离线解决方案,那么您最好设置一个本地数据库。有关说明,您可以阅读switch2osm 上的服务磁贴 howto并跳过 Apache/mod_tile/mapnik 步骤。进口提取物而不是整个星球通常就足够了。相反,实时解析 XML 文件会非常慢,除非您有一个非常小的区域,比如一个城市,并且您事先进行了一些过滤。

于 2013-10-26T19:34:30.863 回答
0

Geoff Boeing 有一个非常漂亮的 OSMnx 包https://geoffboeing.com/tag/osmnx/ 您可以通过 OSM 轻松获得附近的所有便利设施。

import osmnx as ox
import geopandas as gpd
place_name = "" (geocoding of polygon)
tags = {'amenity': 'charging_station'}
ox.geometries_from_place(place_name, tags)
于 2021-01-25T13:43:53.410 回答