栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python 计算tif图像四个角的经纬度坐标

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python 计算tif图像四个角的经纬度坐标

from osgeo import gdal
def calculate(tif_path,comboxIndex):
    dataset = gdal.Open(tif_path + "/" + os.listdir(tif_path)[comboxIndex])  # 打开tif
    geo_information = dataset.GetGeoTransform()
    col = dataset.RasterXSize  # 行数
    row = dataset.RasterYSize  # 列数
    # band = dataset.RasterCount  # 波段

    top_left_corner = [0, 0]  # 左上角
    bottom_left_corner = [col, 0]  # 左下角
    top_right_corner = [0, row]  # 右上角
    bottom_right_corner = [col, row]  # 右下角

    # 左上角经纬度
    top_left_corner_lon = geo_information[0] + top_left_corner[0] * geo_information[1] + top_left_corner[1] * geo_information[2]
    top_left_corner_lat = geo_information[3] + top_left_corner[0] * geo_information[4] + top_left_corner[1] * geo_information[5]

    # 左下角经纬度
    bottom_left_corner_lon = geo_information[0] + bottom_left_corner[0] * geo_information[1] + bottom_left_corner[1] * geo_information[2]
    bottom_left_corner_lat = geo_information[3] + bottom_left_corner[0] * geo_information[4] + bottom_left_corner[1] * geo_information[5]

    # 右上角经纬度
    top_right_corner_lon = geo_information[0] + top_right_corner[0] * geo_information[1] + top_right_corner[1] * geo_information[2]
    top_right_corner_lat = geo_information[3] + top_right_corner[0] * geo_information[4] + top_right_corner[1] * geo_information[5]

    # 右下角经纬度
    bottom_right_corner_lon = geo_information[0] + bottom_right_corner[0] * geo_information[1] + bottom_right_corner[1] * geo_information[2]
    bottom_right_corner_lat = geo_information[3] + bottom_right_corner[0] * geo_information[4] + bottom_right_corner[1] * geo_information[5]
    return top_left_corner_lon,top_left_corner_lat,bottom_left_corner_lon,bottom_left_corner_lat,top_right_corner_lon,top_right_corner_lat,bottom_right_corner_lon,bottom_right_corner_lat

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/915958.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号