复制地理信息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)

相关推荐
屿华AI7 小时前
AUTOSAR 实战-诊断工具 | DTC/Event/FiM 故障报告自动化:DEM 诊断数据采集与解析
python·测试工具·自动化·汽车
贝壳6907 小时前
9.13.12 那三个新功能,我一个一个跑了一遍:两个真香,一个有前提
python
2601_967980117 小时前
Python 与云计算:AWS、GCP、Azure 实践
python·云计算·azure·aws·gcp
屿华AI7 小时前
AUTOSAR 实战-诊断工具 | 基于 Python 与 USB-CANFD 的 UDS 诊断测试工具设计与实现
开发语言·python·测试工具
贝壳6908 小时前
三家 AI 把我的实测数据判成造假,我在同一台机器上重跑了五组
python
用户019027581618 小时前
Telegram Bot 股票到价提醒:AlphaFeed 轮询 + sendMessage
python
黑客笔记9 小时前
Python 进程池和线程池:用等待任务理解并发
开发语言·python
卷无止境9 小时前
Python 开发中的资源管理:统一生命周期,保留资源差异
后端·python
新*9 小时前
520 万数据迁移实战:Elasticsearch 索引重建与"改名"的完整踩坑记录
python·mysql·elasticsearch·数据迁移
吴名氏.10 小时前
Java转AI Agent教程(第十五周)政策时效:过期政策不该被召回,也不能被删掉
java·人工智能·python·ai·ai agent