dth54864 2013-03-27 12:17 采纳率: 0%
浏览 690

从openstreetmap获取城市边界

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 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?