First of all, to be able to address inquiries to the photo, the query must be open GPS photo shoot, with the original time and upload ......
Pictures exif information query, use exifread package
import exifread img = exifread.process_file(open(path), 'rb') longitude = img['GPS GPSLongitude'] latitude = img['GPS GPSLatitude']
It is recommended, you can find a exif viewer upload a picture look, there is a visual impression of the GPS GPSLongitude information
Here, I spent a pit only to find the longest time. Phenomenon after I finished reading the result is always [], print (resp.text) find the latitude and longitude did not read into it. type (longitude) found that this is <class 'exifread.classes.IfdTag'> object. Too, that I did not get to worthy causes. After the lesson is: unused for a tool that can output a step by step look at the results of what it is.
longitude_gps = longitude.values latitude_gps = latitude.values
Next, I started do not know, get a degree every minute of latitude and longitude, latitude and longitude need to be converted to decimal
Conversion formula degrees minutes + / + 60 sec / 3600, to give longitude_new, latitude_news
Previous lessons learned, longitude_gps [0], longitude_gps [1], longitude_gps [2] are in degrees, minutes, seconds, but use the method to get the value .num
Logically, we have the minutes and seconds of latitude and longitude have been converted for the final step.
Requests Import Import JSON URL = 'LOCATION & https://restapi.amap.com/v3/geocode/regeo?key= {} = {}' # see Analytical high inverse de API documentation geographical location = '{}, {} '.format (longitude_new, latitude_news) api_key =' sdasadsadsad '# apply to become a high moral individual developers. The application manager can add RESP = requests.get (url.format (api_key, LOCATION)) Data = json.loads (resp.text) address = data.get ( 'regeocode'). GET ( 'formatted_address,') Print (address )
Look back over, there are two issues is found in the actual test.
1. latitude and longitude, providing high moral 6 after the decimal point, so offer it, you can use the function round
2. longitude_gps [2] when the integer is no problem, but will encounter the situation of m / n, which can not be directly operation, there will be a large error. Change (str (latitude_gps [-1])) is calculated as eval.