参考链接: Python | 反向地理编码以使用地理坐标获取地图上的位置

api地理编码

Motivation

动机

In my second semester of my Master’s degree, I was working on a dataset which had all the records of the road accident in Victoria, Australia (2013-19). I was very curious to know, which national highways are the most dangerous in Victoria, and need attention to improve safety. The dataset did have the longitude and latitude coordinates where the accidents occurred, but it did not have other supporting and useful information like the name of roads where the accident took place, or the suburb, LGA etc. So I thought there must be a way to retrieve that information and analyse it, since its all geographic information which should be linked to the location coordinates. The answer was extracting the information through the process of reverse-geocoding.

在攻读硕士学位的第二学期,我正在研究一个数据集,其中包含澳大利亚维多利亚州(2013-19年)道路交通事故的所有记录。 我很好奇,维多利亚州哪些国道最危险,需要注意以提高安全性。 该数据集确实具有发生事故的经度和纬度坐标,但是它没有其他支持和有用的信息,例如发生事故的道路名称,郊区,LGA等。因此,我认为必须有一种方法检索并分析该信息,因为应该将所有地理信息链接到位置坐标。 答案是通过反向地理编码来提取信息。

What does Geocoding/Reverse-geocoding mean?

地理编码/反向地理编码是什么意思?

Geocoding is the process of converting addresses (like “1600 Amphitheatre Parkway, Mountain View, CA”) into geographic coordinates (like latitude 37.423021 and longitude -122.083739). This might be very useful if your planning to visualise the concentration of your data points in a map. Reverse geocoding is the process of converting geographic coordinates into a human-readable address. If you have good wrangling skills, you can extract other useful information like the nearby street/highway, district area or a landmark.

地理编码是将地址(如“ 1600 Amphitheatre Parkway,Mountain View,CA”)转换为地理坐标(如纬度37.423021和经度-122.083739)的过程。 如果您计划可视化地图中数据点的集中度,这可能非常有用。 反向地理编码是将地理坐标转换为人类可读地址的过程。 如果您有良好的摔跤技巧,则可以提取其他有用的信息,例如附近的街道/高速公路,地区或地标。

My aim was to use reverse-geocoding to extract the name of the highways on which those accidents occurred. There are many platforms available for geocoding, but I used the Google Maps Platform. It is one of the best platforms available which gives you accurate and detailed information. It also offers free services for up to 100,000 requests.

我的目的是使用反向地理编码来提取发生这些事故的高速公路的名称。 有许多可用于地理编码的平台,但是我使用了Google Maps Platform。 它是可为您提供准确和详细信息的最佳平台之一。 它还为多达100,000个请求提供免费服务。

Implementation for Reverse-Geocoding

反向地理编码的实现

I have used python here to implement reverse-geocoding.

我在这里使用python来实现反向地理编码。

Step 1: — Get your Google API Key and enable Geocoding API service. You can refer to this YouTube link to help you set it up.

步骤1:—获取您的Google API密钥并启用地址解析API服务。 您可以参考此YouTube 链接来帮助您进行设置。

Step 2: — Use the reverse_geocode function which converts the location coordinates and receives API output.

步骤2:—使用reverse_geocode函数转换位置坐标并接收API输出。

Remember you have to the input the location coordinates as a tuple. I have provided a screenshot of my implementation which converts 10 location coordinates and retrieves information in JSON format about the region via the API.

记住,您必须以元组的形式输入位置坐标。 我提供了实现的屏幕截图,该屏幕截图可转换10个位置坐标,并通过API以JSON格式检索有关该区域的信息。

Fig 2 Code Snippet

图2代码段

Note: For geocoding you have to use the ‘geocode(<address>)’ method. The result should be stored in a list of size 2.

注意:对于地理编码,您必须使用'geocode(<address>)'方法。 结果应存储在大小为2的列表中。

Step3: — Extracting the information in the API output to get the required information.

步骤3:—在API输出中提取信息以获取所需的信息。

This is perhaps the trickiest part of the implementation especially in reverse geocoding. There is a lot of information retrieved and you might need to wrangle the data you want before any analysis. Here’s how the output of one set of location coordinates i.e. (-37.81125,144.93391) in the above data frame looks like: -

这可能是实现过程中最棘手的部分,尤其是在反向地理编码中。 检索到很多信息,您可能需要在进行任何分析之前先整理所需的数据。 这是上述数据框中的一组位置坐标即(-37.81125,144.93391)的输出如下所示:-

Fig 3 JSON output

图3 JSON输出

As you can clearly see in the output, the accident occurred on the ‘City Link’ Highway in Victoria.

从输出中可以清楚地看到,事故发生在维多利亚州的“ City Link”高速公路上。

The problem I faced here was that the API output from all the accident records was not always in the same format as above. Many of them had different information put in different places. Hence I had to use my wrangling skills to extract the required information from each response.

我在这里遇到的问题是,所有事故记录的API输出并不总是与上述格式相同。 他们中许多人在不同的地方放置了不同的信息。 因此,我不得不使用自己的争吵技巧从每个响应中提取所需的信息。

So, I came up with the idea of extracting the route number of the highway instead of the name on which the accidents occurred. The highways in Victoria are numbered in the pattern starting with ‘M’ and a number. For example, M2 here is the ‘City Link Highway’ or also known as the Western Link. This format was very easy to extract using ‘re’ package of python since it followed a definite pattern. After the extraction, I was easily able to convert these codes to their respective Highway names. I have provided an illustration of that code as well.

因此,我想到了提取高速公路的路线号而不是事故发生的名称的想法。 维多利亚州的高速公路以“ M”和一个数字开头。 例如,这里的M2是“城市链接高速公路”或也称为“西方链接”。 这种格式很容易使用python的“ re”包提取,因为它遵循确定的模式。 提取后,我可以轻松地将这些代码转换为各自的公路名称。 我也提供了该代码的说明。

Note: You can also access the data through the JSON hierarchy, but then again it might not be the same always.

注意:您也可以通过JSON层次结构访问数据,但是同样,它也不一定总是相同的 。

Fig 4 Code Snippet

图4代码段

Mission Accomplished!

任务完成!

I personally really enjoyed the process of getting more information to support my analysis of the data set. It gave me deeper insights and understanding of the frequency of road accidents taking place in Victoria. Many times the information is not as detailed as you would expect and you will have to merge other data sets to get more value out of your main data set. If the above explanations are not clear, do reach out to me via Linkedin & I will be happy to assist you. Thank You!

我个人真的很喜欢获得更多信息以支持我对数据集进行分析的过程。 它使我对维多利亚州发生道路交通事故的频率有了更深刻的了解和理解。 很多时候,信息没有您期望的那么详细,您将不得不合并其他数据集以从主数据集中获得更多价值。 如果以上解释不清楚,请通过Linkedin与我联系,我们很乐意为您提供帮助。 谢谢!

翻译自: https://medium.com/swlh/making-more-sense-of-your-data-through-geocoding-api-3bcbc609c993

api地理编码

[转载] api地理编码_通过地理编码API使您的数据更有意义相关推荐

  1. api地理编码_通过地理编码API使您的数据更有意义

    api地理编码 Motivation 动机 In my second semester of my Master's degree, I was working on a dataset which ...

  2. r语言处理数据集编码_在强调编码语言或工具之前,请学习这3个基本数据概念

    r语言处理数据集编码 重点 (Top highlight) I got an Instagram DM the other day that really got me thinking. This ...

  3. python 分类变量编码_深度学习编码分类变量的3种方法——AIU人工智能学院

    :数据科学.人工智能从业者的在线大学. 数据科学(Python/R/Julia) 作者 | CDA数据分析师 像Keras中的机器学习和深度学习模型一样,要求所有输入和输出变量均为数字. 这意味着,如 ...

  4. 算法训练营 重编码_我在编码训练营中的经验(以及是否适合您)

    算法训练营 重编码 by Florian Mueller 通过弗洛里安·穆勒(Florian Mueller) 我在编码训练营中的经验(以及是否适合您) (My experience with a c ...

  5. 曼彻斯特编码_两种编码方式以及两种帧结构

    一.不归零制编码(Non-Return to Zero) 对于不归零制编码是最简单的一种编码方式,正电平代表1,负电平代表0.如下图: 其实在不归零制编码中有一个很明显的缺陷,那就是它不是自同步码. ...

  6. mysql 数据库编码怎么看,查看数据库编码_查看mysql编码方式 mysql数据库编码查看方法...

    摘要 腾兴网为您分享:查看mysql编码方式 mysql数据库编码查看方法,桌面日历,智能互联,政务易,优美图等软件知识,以及pptv版,广东省app,京东钱包app,星露谷物语补丁,51管家,翡翠出 ...

  7. loinc编码_通用检验编码系统(Universal Laboratory Test Code System)于香港电子健康纪录计划的应用...

    原标题:通用检验编码系统(Universal Laboratory Test Code System)于香港电子健康纪录计划的应用 通用检验编码系统(Universal Laboratory Test ...

  8. 创建表 编码_创建没有编码的专业商业网站

    创建表 编码 Do you have a great idea for an online business, but lack the technical skills to build a web ...

  9. java费诺编码_费诺编码的分析与实现.doc

    费诺编码的分析与实现 吉林建筑大学 电气与电子信息工程学院 设计题目: 费诺编码的分析与实现 专业班级: 电子信息工程 111 学生姓名: 马 超 学 号: 指导教师: 吕卅 王超 设计时间: 201 ...

最新文章

  1. 最长公共子序列(JAVA实现)
  2. 【数据结构】数据结构知识思维导图
  3. 安徽关节式焊接机器人_上下料机器人的重要性体现在哪里?它有哪些优势?
  4. -le: unary operator expected_【AFM+STM-LE】超经典:研究单分子化学反应引起的光发射ACS Nano...
  5. 用SegNet进行室内布局语义分割
  6. Python MySQL示例教程
  7. action中的动态方法调用
  8. Ubuntu 16.04 Apache https证书安装
  9. 加多宝李二强:营销数字化闭环初体验,真的很爽
  10. 域格LPM2100 me NB模块PSM相关问题
  11. 下载多张图片并压缩成压缩包
  12. html5小游戏跑,HTML5 Speedster 小游戏(高速跑跳过关)
  13. 农夫过河问题的c语言实现
  14. jQuery选择器代码详解(一)——Sizzle方法
  15. 计算机硬盘不能存储文件,磁盘已满,文件无法保存怎么弄
  16. qt中制作添加 .ts 翻译文件
  17. 人工智能中的常用搜索策略
  18. flex弹性布局教程-04项目属性flex-grow
  19. Android开发必须掌握!做了3年Android还没看过OkHttp源码?挥泪整理面经
  20. 【医学图像处理】3 图像梯度及边缘提取

热门文章

  1. java命令行编译命令_Java使用命令行编译运行程序
  2. 操作系统—处理机调度
  3. 远程命令,代码执行漏洞原理
  4. UnityShader15:前向渲染
  5. OpenGL基础19:法向量与漫反射
  6. bzoj 1614: [Usaco2007 Jan]Telephone Lines架设电话线(二分+SPFA)
  7. 高斯滤波详解 python实现高斯滤波
  8. C++ STL 遍历vector
  9. [PyTorch] PyTorch版本不兼容问题+更新日志链接
  10. prometheus-operator架构部署( prometheus-server, pushgateway, grafana, alertmanater,servicemonitor...)