分享

几个地理编码工具

 风声之家 2022-06-29 发布于江苏

原创 西西艾尔 GIS二师兄 2022-06-29 11:06 发表于浙江

地理编码就是将地名地址转换为地理坐标(正向编码)或相反的操作把地理坐标转换为标准地址(反向编码)。下面介绍几个免费用于地理编码的搜索引擎。

1、Nominatim

Nominatim是OpenStreetMap数据搜索引擎。你可以搜索名称或地址(正向搜索)或按地理坐标搜索数据(反向搜索)。每个结果都带有一个指向详细信息页面的链接,可以在其中检查有关对象哪些数据存储在数据库中,并调查对象的地址是如何计算的。在开始使用 Nominatim 之前,最好阅读他们的使用政策。

Nominatim API

它的 API 具有以下用于查询数据的端点:
  • /search – 按名称或类型搜索 OSM 对象。

  • /reverse – 按位置查找 OSM 对象。

  • /lookup – 通过 ID 查找 OSM 对象的地址详细信息。

  • /status – 检查服务器的状态。

  • /deletable – 列出已在 OSM 中删除但由 Nominatim 保留的对象,以防意外删除。

  • /polygons – Nominatim 检测到的破碎多边形列表。

  • /details - 显示对象的内部详细信息(仅用于调试)。

    此外,Nominatim API 允许:

  • 定义以下输出格式:xml、json、jsonv2、geojson 和 geocodejson。

  • 指明结果的语言。

  • 限制结果的数量。

  • 多边形输出。

例子

对地址的请求示例如下:

https://nominatim./search?q=Calle%20del%20Universo,%20Pilarica,%20Valladolid,%20Castilla%20y%20Le%C3%B3n,%2047011,%20Espa%C3%B1a&json_callback=_l_osmgeocoder_3&format=json
如我们所见,我们使用参数 q= 后跟地址:街道、城市、地区、邮政编码、国家。
得到的结果是:

_l_osmgeocoder_3([{"place_id":118312501,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. https:///copyright","osm_type":"way","osm_id":75689481,"boundingbox":["41.6569033","41.6587214","-4.6990298","-4.6983179"],"lat":"41.6579667","lon":"-4.6988994","display_name":"Calle del Universo, Pilarica - Los Santos, Valladolid, Castilla y León, 47011, España","class":"highway","type":"residential","importance":1.13}])

2、ArcGIS

换为地址。该服务为部分地址和地名文本提供建议的候选地址。许多地址也可以通过批量地理编码一次进行地理编码。
该服务的特点是:
  • 地理编码地址并查找世界各地的地点。

  • 按类别类型过滤地点搜索。

  • 以不同的语言和地点返回候选人。

  • 返回不同空间参考中的候选者。

  • 按位置、分机、城市和国家代码优化您的搜索。

  • 返回每个候选人的特定数据字段。

  • 限制返回的候选人数量。

  • 返回PointAddress候选者的屋顶或街道位置。

  • 指定要包含在输出字段中的城市名称或街道名称的类型。

例子

让我们看看使用 ArcGIS 的相同请求的输出:

https://geocode./arcgis/rest/services/World/GeocodeServer/findAddressCandidates?outSr=4326&forStorage=false&outFields=*&maxLocations=5&singleLine=Calle del Universo, Pilarica, Valladolid, Castilla y León, 47011, España&f=json
结果是:

{"spatialReference":{"wkid":4326,"latestWkid":4326},"candidates":[{"address":"Calle del Universo, 47011, Pilarica-Los Santos, Valladolid, Castilla y León","location":{"x":-4.698406173043292,"y":41.652594027432421},"score":98.200000000000003,"attributes":{"Loc_name":"World","Status":"M","Score":98.200000000000003,"Match_addr":"Calle del Universo, 47011, Pilarica-Los Santos, Valladolid, Castilla y León","LongLabel":"Calle del Universo, 47011, Pilarica-Los Santos, Valladolid, Castilla y León, ESP","ShortLabel":"Calle del Universo","Addr_type":"StreetName","Type":"","PlaceName":"","Place_addr":"Calle del Universo, 47011, Pilarica-Los Santos, Valladolid, Castilla y León","Phone":"","URL":"","Rank":20,"AddBldg":"","AddNum":"","AddNumFrom":"","AddNumTo":"","AddRange":"","Side":"","StPreDir":"","StPreType":"Calle del","StName":"Universo","StType":"","StDir":"","BldgType":"","BldgName":"","LevelType":"","LevelName":"","UnitType":"","UnitName":"","SubAddr":"","StAddr":"Calle del Universo","Block":"","Sector":"","Nbrhd":"Pilarica-Los Santos","District":"Valladolid","City":"Valladolid","MetroArea":"","Subregion":"Valladolid","Region":"Castilla y León","RegionAbbr":"CL","Territory":"","Zone":"","Postal":"47011","PostalExt":"","Country":"ESP","CntryName":"España","LangCode":"SPA","Distance":0,"X":-4.698406173043292,"Y":41.652594027432421,"DisplayX":-4.698406173043292,"DisplayY":41.652594027432421,"Xmin":-4.6994061730432923,"Xmax":-4.6974061730432917,"Ymin":41.651594027432424,"Ymax":41.653594027432419,"ExInfo":""},"extent":{"xmin":-4.6994061730432923,"ymin":41.651594027432424,"xmax":-4.6974061730432917,"ymax":41.653594027432419}}]}

3. MapBox

Mapbox地理编码API执行两个主要任务:正向地理编码和反向地理编码。Mapbox 地理编码 API 包含来自政府、开放数据项目和私营公司的数据源。在某些情况下,Geocoding API 结果可能与 Mapbox Streets 或 OpenStreetMap 数据不同。
MapBox 地理编码服务非常完整,它的文档非常好,这就是为什么它是了解其工作原理的最佳方式。有两个不同的部分:我们用来定义位置的源数据,以及我们用来查找和返回这些位置的工具。
Mapbox Geocoding API 源数据包含以下类型的地理信息,按从最细到最大的顺序排列:
  • 兴趣点 (POI):一个命名的地方,包括商业企业、公共建筑、纪念碑和公园,以及其他特征。

  • 地址:具体的邮寄地址,包括地址号码(如果适用)。

  • Barrio:一个地方内较小区域的俗称。社区不一定有特定的法律定义的边界。仅存在于某些国家。

  • 地方:比地方小的行政单位。仅存在于某些国家。

  • 邮政编码:用于对邮件进行分类的地址组件的地理区域。

  • 地点:城市、城镇和村庄。请注意,一些大城市(如东京和伊斯坦布尔)可能被归类为区域而不是地方。

  • 区:大于一个地方但小于一个地区的行政单位。仅存在于某些国家。

  • 地区:州、省、州。这通常是一个国家最大的地方行政单位。请注意,一些大城市(如东京和伊斯坦布尔)可能被归类为区域而不是地方。

  • 国家:公认的国家或在某些情况下,如香港,一个准国家行政区,已根据 ISO 3166-1 分配了指定的国家代码。

例子

我们可以提出如下请求:

https://api./geocoding/v5/mapbox.places/Calle%20del%20Universo%2C%20Pilarica%2C%20Valladolid%2C%20Castilla%20y%20Le%C3%B3n%2C%2047011%2C%20Espa%C3%B1a.json?types=place%2Cpostcode%2Caddress&access_token=pk.eyJ1IjoibmFkaXJpbmciLCJhIjoiY2tob2phbXVoMDE4cjJ6cnN6Nmh5eWRpeSJ9.-9CD1Qdet6QZ0-la9X-WxA
我们得到的结果是:

{"type":"FeatureCollection","query":["calle","del","universo","pilarica","valladolid","castilla","y","león","47011","españa"],"features":[{"id":"address.6646104522414774","type":"Feature","place_type":["address"],"relevance":0.667111,"properties":{"accuracy":"street"},"text":"Avenida De Castilla Y León","place_name":"Avenida De Castilla Y León, 47170 Renedo de Esgueva, Valladolid, Spain","matching_place_name":"Avenida De Castilla Y León, 47170 Renedo de Esgueva, Valladolid, España","center":[-4.62078657077973,41.6490973915293],"geometry":{"type":"Point","coordinates":[-4.62078657077973,41.6490973915293]},"context":[{"id":"postcode.14752399392272030","text":"47170"},{"id":"place.14752399393990660","wikidata":"Q965817","text":"Renedo de Esgueva"},{"id":"region.3914000952560650","short_code":"ES-VA","wikidata":"Q71097","text":"Valladolid"},{"id":"country.12507185778570100","wikidata":"Q29","short_code":"es","text":"Spain"}]},{"id":"address.8952949467012426","type":"Feature","place_type":["address"],"relevance":0.563037,"properties":{"accuracy":"street"},"text":"Calle Del Universo","place_name":"Calle Del Universo, 47011 Valladolid, Valladolid, Spain","matching_place_name":"Calle Del Universo, 47011 Valladolid, Valladolid, España","center":[-4.69815570337461,41.6537263736091],"geometry":{"type":"Point","coordinates":[-4.69815570337461,41.6537263736091]},"context":[{"id":"postcode.5701413129104160","text":"47011"},{"id":"place.12363438835560650","wikidata":"Q8356","text":"Valladolid"},{"id":"region.3914000952560650","short_code":"ES-VA","wikidata":"Q71097","text":"Valladolid"},{"id":"country.12507185778570100","wikidata":"Q29","short_code":"es","text":"Spain"}]},{"id":"postcode.18741841314104160","type":"Feature","place_type":["postcode"],"relevance":0.440074,"properties":{},"text":"47011","place_name":"47011, Castrocaro Terme e Terra del Sole, Forlì-Cesena, Italy","matching_place_name":"47011, Castrocaro Terme e Terra del Sole, Forlì-Cesena, Ý","bbox":[11.88861,44.130406,11.98557,44.210908],"center":[11.955631,44.182365],"geometry":{"type":"Point","coordinates":[11.955631,44.182365]},"context":[{"id":"place.18741841313723480","wikidata":"Q99936","text":"Castrocaro Terme e Terra del Sole"},{"id":"region.9737127769415150","short_code":"IT-FC","wikidata":"Q16180","text":"Forlì-Cesena"},{"id":"country.2840014219519910","wikidata":"Q38","short_code":"it","text":"Italy"}]},{"id":"postcode.5701413129104160","type":"Feature","place_type":["postcode"],"relevance":0.375778,"properties":{},"text":"47011","place_name":"47011, Valladolid, Valladolid, Spain","matching_place_name":"47011, Valladolid, Valladolid, España","bbox":[-4.726197,41.643888,-4.630816,41.69241],"center":[-4.711764,41.659246],"geometry":{"type":"Point","coordinates":[-4.711764,41.659246]},"context":[{"id":"place.12363438835560650","wikidata":"Q8356","text":"Valladolid"},{"id":"region.3914000952560650","short_code":"ES-VA","wikidata":"Q71097","text":"Valladolid"},{"id":"country.12507185778570100","wikidata":"Q29","short_code":"es","text":"Spain"}]},{"id":"place.12363438835560650","type":"Feature","place_type":["place"],"relevance":0.359333,"properties":{"wikidata":"Q8356"},"text":"Valladolid","place_name":"Valladolid, Valladolid, Spain","matching_place_name":"Valladolid, Valladolid, España","bbox":[-4.92818,41.523328,-4.630816,41.815508],"center":[-4.728562,41.652133],"geometry":{"type":"Point","coordinates":[-4.728562,41.652133]},"context":[{"id":"region.3914000952560650","short_code":"ES-VA","wikidata":"Q71097","text":"Valladolid"},{"id":"country.12507185778570100","wikidata":"Q29","short_code":"es","text":"Spain"}]}],"attribution":"NOTICE: © 2022 Mapbox and its suppliers. All rights reserved. Use of this data is subject to the Mapbox Terms of Service (https://www./about/maps/). This response and the information it contains may not be retained. POI(s) provided by Foursquare."}

4. Bing Maps

Bing 地图位置 API允许您
  • 按地址搜索位置。通过指定城市、邮政编码、街道地址等值来获取某个位置的经纬度坐标。

  • 通过点的坐标查找位置。获取与经纬度坐标相关的位置信息。

  • 通过查询搜索位置。获取与作为查询字符串提供的位置信息相对应的纬度和经度坐标。

  • 位置意识。获取位置信息,例如本地商户、自然兴趣点以及反向地理编码地址到指定的经纬度坐标。

  • 本地搜索。使用文本查询或业务类型搜索附近的本地企业。

例子

我们执行与前面示例中相同的查询:

http://dev./REST/v1/Locations/Calle%20del%20Universo%20Pilarica%20Valladolid%20Castilla%20y%20León%2047011%20España?o=xml&key=Tuclave
您需要在 URL 的 key 参数中使用 Bing 键。
图片

5. MapTiler

Maptiler是一个用于在云中创建和发布地图的平台。它有一个具有以下特点的地理编码工具。
  • 交互式搜索的快速答案。

  • 使用语言偏好搜索。

  • 将搜索限制在给定的范围内。

  • 邻近搜索。

  • 反向地理编码。

只需编写以下代码,我们就可以轻松构建一个自动完成搜索控件以包含在我们的 web 地图中:



















<!DOCTYPE html><html><head><script src="https://cdn./maptiler-geocoder/v1.1.0/maptiler-geocoder.js"></script><link href="https://cdn./maptiler-geocoder/v1.1.0/maptiler-geocoder.css" rel="stylesheet" /></head><body><input autocomplete="off" id="search" type="text" /><script>var geocoder = new maptiler.Geocoder({input: 'search',key: 'lmHOKzOjrAHjj7ThE6bO'      });      geocoder.on('select', function(item) {console.log('Selected', item);      });</script></body></html>
图片

将此控件插入到 Leaflet 地图中并将地图居中于获得的坐标上,可以按如下方式完成:









































<!DOCTYPE html><html><head><meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /><link rel="stylesheet" href="https://cdnjs./ajax/libs/leaflet/1.7.1/leaflet.css" /><script src="https://cdnjs./ajax/libs/leaflet/1.7.1/leaflet.js"></script><script src="https://cdn./maptiler-geocoder/v1.1.0/maptiler-geocoder.js"></script><link href="https://cdn./maptiler-geocoder/v1.1.0/maptiler-geocoder.css" rel="stylesheet" /><style>#map {position: absolute; top: 0; right: 0; bottom: 0; left: 0;}</style></head><body>
<div id="map"><input autocomplete="off" id="search" type="text" /><a href="https://www." style="position:absolute;left:10px;bottom:10px;z-index:999;"><img src="https://api./resources/logo.svg" alt="MapTiler logo"></a></div><p><a href="https://www./copyright/" target="_blank">© MapTiler</a> <a href="https://www./copyright" target="_blank">© OpenStreetMap contributors</a></p><script>var map = L.map('map').setView([0, 0], 1); L.tileLayer('https://api./maps/basic/{z}/{x}/{y}.png?key=lmHOKzOjrAHjj7ThE6bO',{tileSize: 512,zoomOffset: -1,minZoom: 1,attribution: "\u003ca href=\"https://www./copyright/\" target=\"_blank\"\u003e\u0026copy; MapTiler\u003c/a\u003e \u003ca href=\"https://www./copyright\" target=\"_blank\"\u003e\u0026copy; OpenStreetMap contributors\u003c/a\u003e",crossOrigin: true }).addTo(map);
var geocoder = new maptiler.Geocoder({input: 'search',key: 'lmHOKzOjrAHjj7ThE6bO' }); geocoder.on('select', function(item) {var x=('Selected', item.center);console.log(x); map.setView([x[1],x[0]],12) });</script></body></html>

6. MapQuest

MapQuest有一个用于地理编码和反向地理编码的 API。但它也有一个重要的特性,就是批量地理编码这允许您一次发送多个正向或反向地理编码请求。在单个批处理请求中最多可以发送 100 个地址或经纬度对。
MapQuest 需要密码才能访问其服务。

7.what3words

这玩意有点争议,What3words是一个以三个单词的唯一代码对地理坐标进行编码的系统。三词地址为世界上每 3 x 3 平方米的面积分配了一个永远不会改变的唯一 3 字地址。这个全球网格包含 570 亿个 3 x 3 米的正方形。
图片

当然,地理编码工具有很多,例如Mapinfo、超图、Google MapsPhoton等 。

确定


  • 不看此公众号

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多