I'm developing a website and I need to get all the boundaries of an area given depending on the user input. For example, the user want to know the boundaries of a city named x. How should I get it from openstreetmap? I've heard of xapi and osmosis but couldnt find any examples anywhere. Thanks!
3条回答 默认 最新
- douwen3362 2013-08-29 03:53关注
I took a stab at doing this with JavaScript here: https://github.com/pgkelley4/city-boundaries-google-maps
Basically it comes down to finding the relation that OpenStreetMap stores the city boundaries as.
I used something like the following query to get the area:
area[name="Seattle"]["is_in:state_code"="WA"];foreach(out;);
Or if that doesn't find anything, going through the node to find any associated areas:
node[name="New York"][is_in~"NY"];foreach(out;is_in;out;);
To get the relation ID, subtract 3600000000 from the area ID returned by the above queries. Then get the relation from its ID:
(relation(" + relationID + ");>;);out;
You can test out queries here, mine could probably be improved on: http://overpass-api.de/query_form.html
That is how to get the city boundaries, processing them is another matter as nothing is in order within the relation. For that see my GitHub project and: http://wiki.openstreetmap.org/wiki/Relation:multipolygon/Algorithm
Also I would note that the OpenStreetMap data for city boundaries is spotty. It is missing for big cities like Dallas and LA from what I can tell.
解决 无用评论 打赏 举报
悬赏问题
- ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
- ¥15 如何在scanpy上做差异基因和通路富集?
- ¥20 关于#硬件工程#的问题,请各位专家解答!
- ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
- ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
- ¥30 截图中的mathematics程序转换成matlab
- ¥15 动力学代码报错,维度不匹配
- ¥15 Power query添加列问题
- ¥50 Kubernetes&Fission&Eleasticsearch
- ¥15 報錯:Person is not mapped,如何解決?