获取的图片的地理位置(经纬)信息,并将其标注在中国地图上

本文介绍了如何通过exifread库获取图片的GPS信息,提取经纬度,并详细说明了如何利用这些信息在中国地图上标注具体位置。提供了完整的代码示例和运行结果,读者可以参考实现相同功能。
摘要由CSDN通过智能技术生成

通过exifread获取图片的GPS信息

	def img_exif(self,img_path):
		tags = exifread.process_file(open(img_path,'rb'))
		print(type(tags)) # 通过exifread.process_file获取的是一个dict
		#for key,value in tags.items():
			#print("The key is %s value is %s" %(key,value))
		# 得知与GPS相关的keys:
		# GPS GPSVersionID GPS 的版本号
		# GPS GPSLatitudeRef 南北半球
		# GPS GPSLatitude 纬度
		# GPS GPSLongitudeRef 东西半球
		# GPS GPSLongitude 经度
		# GPS GPSAltitudeRef  0 = 海平面以上  1 = 海平面以下
		# GPS GPSAltitude  海拔高度
		# GPS GPSTimeStamp 时间戳 
		# GPS GPSProcessingMethod 定位方式
		# GPS GPSDate 定位日期
		obtain_gps = [tags['GPS GPSLongitude'], tags['GPS GPSLatitude'], tags['GPS GPSLongitudeRef'],
						tags['GPS GPSLatitudeRef'], tags['GPS GPSAltitude'], tags['GPS GPSAltitudeRef']]
		return obtain_gps

与exifread相关的网址链接https://pypi.org/project/ExifRead/,该链接中对exifread库进行了详细的介绍
通过tags = exifread.process_file(open(img_path,'rb'))语句可以获取图片的相关信息,返回的是一个dict

对于字典的访问

		for key,value in tags.items():
			print("The key is %s value is %s" %(key,value))

得到键和值如下所示,

The key is Image ImageWidth value is 3456
The key is Image ImageLength value is 4608
The key is Image BitsPerSample value is [8, 8, 8]
The key is Image Make value is HUAWEI
The key is Image Model value is PAR-AL00
The key is Image Orientation value is 0
The key is Image XResolution value is 72
The key is Image YResolution value is 72
The key is Image ResolutionUnit value is Pixels/Inch
The key is Image Software value is PAR-AL00 9.1.0.321(C00E320R1P1)
The key is Image DateTime value is 2019:08:27 16:37:35
The key is Image YCbCrPositioning value is Centered
The key is Image ExifOffset value is 286
The key is GPS GPSVersionID value is [2, 2, 0, 0]
The key is GPS GPSLatitudeRef value is N
The key is GPS GPSLatitude value is [34, 29, 6493103/200000]
The key is GPS GPSLongitudeRef value is E
The key is GPS GPSLongitude value is [107, 53, 52919311/1000000]
The key is GPS GPSAltitudeRef value is 0
The key is GPS GPSAltitude value is 17689/25
The key is GPS GPSTimeStamp value is [8, 37, 32]
The key is GPS GPSProcessingMethod value is GPS
The key is GPS GPSDate value is 2019:08:27
The key is Image GPSInfo value is 8518
The key is Image DeviceSettingDescription value is [105, 112, 112, 0]
The key is Thumbnail ImageWidth value is 384
The key is Thumbnail ImageLength value is 512
The key is Thumbnail Compression value is JPEG (old-style)
The key is Thumbnail Orientation value is 0
The key is Thumbnail XResolution value is 72
The key is Thumbnail YResolution value is 72
The key is Thumbnail ResolutionUnit value is Pixels/Inch
The key is Thumbnail JPEGInterchangeFormat value is</
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值