Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use python to realize geocoding

Shulou Source: shulou.com Published: 2022-06-02 09:45:36 09月19日 Update

This article focuses on "how to use python to achieve geocoding", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn "how to use python to achieve geocoding"!

Python realizes geocoding and goes to Amap to apply for a good key

Python code #-*-coding:utf_8-*-#! / usr/bin/python37 "" @ author:renyuan@software:PyCharm@file: Hunan village. Py@time:2021/5/12 001221 coding:utf_8 17 "import requestsimport jsonimport pandas as pd## reads the Excel file df_address = pd.read_excel ('Excel file where the address entered') # # constructs urldf_address ['url'] =' https://restapi.amap. Com/v3/geocode/geo?address='+df_address ['address column'] +'& output=JSON&key= enter your key'## to create an empty df Used to receive file result = pd.DataFrame ([]) for url in df_address ['url']: # # get request response = requests.get (url) # # return json file persons = json.loads (response.text) # # json file parsing for person in persons [' geocodes']: dict = {} dict = person df = pd.DataFrame ([dict]) # # File append result = result.append (df, ignore_index=False) print (result) result.to_csv ('results.csv', index=False)

Coordinate correction

Here take a plug-in.

The Gaud coordinates use Martian coordinates, so we take Martian coordinates to transform Earth coordinates.

ArcGISPro performs XY turning point

Export data

Effect.

At this point, I believe you have a deeper understanding of "how to use python to achieve geocoding". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Files coordinates geography coding content location Mars Gaud learning input utility deeper code interest map address earth practicality reality plug-ins Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Apple Xiaomi NVidia Linux