Exemple #1
0
    """
    remainder, degrees = math.modf(abs(decimal))
    remainder, minutes = math.modf(remainder * 60)
    return [Fraction(n) for n in (degrees, minutes, remainder * 60)]



tup_photos = li_photos(r'test\img')
li_pts = []

for photo in tup_photos:
    """ explore exif geotags of each photo """
    print '\n', path.basename(photo)
    # with EXIF (https://github.com/ianare/exif-py)
    with open(photo, 'r') as tof:
        tags = EXIF.process_file(tof)
        coord_EXIF = (str(tags.get('GPS GPSLatitude')), str(tags.get('GPS GPSLongitude')), str(tags.get('GPS GPSAltitude')))
    # with pyexiv2
    md = pyexiv2.ImageMetadata(photo)
    md.read()
    lat = md.__getitem__("Exif.GPSInfo.GPSLatitude")
    latRef = md.__getitem__("Exif.GPSInfo.GPSLatitudeRef")
    lon = md.__getitem__("Exif.GPSInfo.GPSLongitude")
    lonRef = md.__getitem__("Exif.GPSInfo.GPSLongitudeRef")

    lat = str(lat).split("=")[1][1:-1].split(" ");
    lat = map(lambda f: str(float(Fraction(f))), lat)
    lat = lat[0] + u"\u00b0" + lat[1] + "'" + lat[2] + '"' + " " + str(latRef).split("=")[1][1:-1]

    lon = str(lon).split("=")[1][1:-1].split(" ");
    lon = map(lambda f: str(float(Fraction(f))), lon)