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

相关推荐
夜雪一千10 小时前
如何使用Python做舆情分析
人工智能·python·数据分析
Ticnix10 小时前
MCP 工具拿不到 user_id?用 contextvars 做请求级用户隔离
python·agent·mcp
gb421528710 小时前
WPS 里的 Word快速合成照片
python
databook11 小时前
Python 常用统计图表实战指南
python·数据分析·数据可视化
wang_yb11 小时前
Python 常用统计图表实战指南
python·数据分析·databook
魔镜er12 小时前
11-循环神经网络
人工智能·pytorch·python·深度学习·神经网络
Patrick在香港12 小时前
Python 抓香港政府公报 RSS:中英两个 feed 的 guid 零重合,lastBuildDate 停在 2016 年
python·数据处理·数据抓取·香港·rss
宁渡AI大模型12 小时前
河南宁渡科技有限公司|宁渡课堂 AI 全栈面试分享,AI 应用开发高频考点汇总
java·c++·人工智能·python·深度学习·神经网络·rag