日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發(fā)布時(shí)間:2023/11/29 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 api地理编码_通过地理编码API使您的数据更有意义 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

api地理編碼

Motivation

動(dòng)機(jī)

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.

在攻讀碩士學(xué)位的第二學(xué)期,我正在研究一個(gè)數(shù)據(jù)集,其中包含澳大利亞維多利亞州(2013-19年)道路交通事故的所有記錄。 我很好奇,維多利亞州哪些國道最危險(xiǎn),需要注意以提高安全性。 該數(shù)據(jù)集確實(shí)具有發(fā)生事故的經(jīng)度緯度坐標(biāo),但是它沒有其他支持和有用的信息,例如發(fā)生事故的道路名稱,郊區(qū),LGA等。因此,我認(rèn)為必須有一種方法檢索并分析該信息,因?yàn)閼?yīng)該將所有地理信息鏈接到位置坐標(biāo)。 答案是通過反向地理編碼來提取信息

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”)轉(zhuǎn)換為地理坐標(biāo)(如緯度37.423021和經(jīng)度-122.083739)的過程。 如果您計(jì)劃可視化地圖中數(shù)據(jù)點(diǎn)的集中度,這可能非常有用。 反向地理編碼是將地理坐標(biāo)轉(zhuǎn)換為人類可讀地址的過程。 如果您有良好的摔跤技巧,則可以提取其他有用的信息,例如附近的街道/高速公路,地區(qū)或地標(biāo)。

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.

我的目的是使用反向地理編碼來提取發(fā)生這些事故的高速公路的名稱。 有許多可用于地理編碼的平臺,但是我使用了Google Maps Platform。 它是可為您提供準(zhǔn)確和詳細(xì)信息的最佳平臺之一。 它還為多達(dá)100,000個(gè)請求提供免費(fèi)服務(wù)。

Implementation for Reverse-Geocoding

反向地理編碼的實(shí)現(xiàn)

I have used python here to implement reverse-geocoding.

我在這里使用python來實(shí)現(xiàn)反向地理編碼。

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服務(wù)。 您可以參考此YouTube 鏈接來幫助您進(jìn)行設(shè)置。

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

步驟2:—使用reverse_geocode函數(shù)轉(zhuǎn)換位置坐標(biāo)并接收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.

記住,您必須以元組的形式輸入位置坐標(biāo)。 我提供了實(shí)現(xiàn)的屏幕截圖,該屏幕截圖可轉(zhuǎn)換10個(gè)位置坐標(biāo),并通過API以JSON格式檢索有關(guān)該區(qū)域的信息。

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>)'方法。 結(jié)果應(yīng)存儲在大小為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: -

這可能是實(shí)現(xiàn)過程中最棘手的部分,尤其是在反向地理編碼中。 檢索到很多信息,您可能需要在進(jìn)行任何分析之前先整理所需的數(shù)據(jù)。 這是上述數(shù)據(jù)框中的一組位置坐標(biāo)即(-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.

從輸出中可以清楚地看到,事故發(fā)生在維多利亞州的“ 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輸出并不總是與上述格式相同。 他們中許多人在不同的地方放置了不同的信息。 因此,我不得不使用自己的爭吵技巧從每個(gè)響應(yīng)中提取所需的信息。

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.

因此,我想到了提取高速公路的路線號而不是事故發(fā)生的名稱的想法。 維多利亞州的高速公路以“ M”和一個(gè)數(shù)字開頭。 例如,這里的M2是“城市鏈接高速公路”或也稱為“西方鏈接”。 這種格式很容易使用python的“ re”包提取,因?yàn)樗裱_定的模式。 提取后,我可以輕松地將這些代碼轉(zhuǎn)換為各自的公路名稱。 我也提供了該代碼的說明。

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

注意:您也可以通過JSON層次結(jié)構(gòu)訪問數(shù)據(jù),但是同樣,它也不一定總是相同的 。

Fig 4 Code Snippet圖4代碼段

Mission Accomplished!

任務(wù)完成!

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!

我個(gè)人真的很喜歡獲得更多信息以支持我對數(shù)據(jù)集進(jìn)行分析的過程。 它使我對維多利亞州發(fā)生道路交通事故的頻率有了更深刻的了解和理解。 很多時(shí)候,信息沒有您期望的那么詳細(xì),您將不得不合并其他數(shù)據(jù)集以從主數(shù)據(jù)集中獲得更多價(jià)值。 如果以上解釋不清楚,請通過Linkedin與我聯(lián)系,我們很樂意為您提供幫助。 謝謝!

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

api地理編碼

總結(jié)

以上是生活随笔為你收集整理的api地理编码_通过地理编码API使您的数据更有意义的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。