复制地理信息python版本

import rasterio

已有正确地理信息的影像

ref_file = r"D:\20220104T172343_truth.tif"

需要添加地理信息的影像

input_file = r"D:\validation\truthimage\20220104T172343_truth.tif"

输出文件

output_file = r"D:\mission\validation\truthimagegeo\20220104T172343_truth.tif"

读取参考影像信息

with rasterio.open(ref_file) as ref:

ref_profile = ref.profile

ref_crs = ref.crs

ref_transform = ref.transform

读取需要添加地理信息的影像

with rasterio.open(input_file) as src:

data = src.read()

profile = src.profile

替换地理信息

profile.update(

crs=ref_crs,

transform=ref_transform

)

保存

with rasterio.open(output_file, "w", **profile) as dst:

dst.write(data)

print("完成:", output_file)

相关推荐
看浪的路人1 小时前
第1讲:Agent 到底是什么?和 Chatbot 有什么区别
python·ai
瓦学妹2 小时前
什么是网络索引?它是如何工作的?
大数据·网络·python·网络爬虫
天天爱吃肉82182 小时前
商用车多体动力学实战笔记|第6篇:动力传动系统(发动机、变速箱、分动器、TCS、LSD限滑差速)
大数据·人工智能·笔记·python·嵌入式硬件·汽车
海盗12343 小时前
微软技术周报 ——2026-08-03
后端·python·microsoft·c#·.netcore
大数据魔法师3 小时前
【最全详解】DuckDB Python 全套 API 语法、参数与实战用法(零基础全覆盖)
python·数据分析
MC皮蛋侠客4 小时前
SQLAlchemy 系列(七):高级建模与高效写入——批量 DML、方言与扩展
数据库·python
Zane19944 小时前
@property 到底是怎么把方法伪装成属性的?一文吃透 property、staticmethod、classmethod
后端·python
qq_316411035 小时前
AI 情感陪伴智能潮玩软硬件一体化开发案例
人工智能·python
废弃的小码农5 小时前
功能测试--Day07--Python编程基础
开发语言·python