Python application: Latitude-matched

Source: Internet
Author: User

Need to install a third-party package: Requests

The latitude and longitude matching using the high-D map API, first of all, the GPS coordinates into the latitude and longitude coordinates of the German map, and then according to the converted coordinates to match.

This match is mainly to get the POI point address information that is closest to a given latitude and longitude.

The main programs are as follows:

1 #-*-coding:utf8-*-2 ImportRequests3 ImportCSV4 ImportChardet5 ImportSYS6 Reload (SYS)7Sys.setdefaultencoding ("UTF8")8 9location='116.81963,40.310799'Ten defGeoCode (location): Oneparameters={' Location': Location,'Key':'7447d3ae24afa6497f1b459fc5cd0419','Extensions':' All'} ABase ='Http://restapi.amap.com/v3/geocode/regeo' -Response =requests.get (base,parameters) -Answer =Response.json () the     Printanswer['Regeocode']['POIs'][0]['name'] -  - defTransform (location): -Parameters = {'Locations': Location,'Coordsys':'GPS','Key':'7447d3ae24afa6497f1b459fc5cd0419'} +Base ='Http://restapi.amap.com/v3/assistant/coordinate/convert' -Response =requests.get (base,parameters) +Answer =Response.json () A     returnanswer['Locations'] at  -      -GeoCode (transform (location))

The results of the operation are as follows:

If you need to get additional address information to output other values in the corresponding answer, the name of the value corresponds to the following:

Python application: Latitude-matched

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.