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

相关推荐
2501_944521591 小时前
Immer 跨端三方库仓颉适配全流程
python·eclipse·django
信誓旦旦的程序猿1 小时前
【Python量化实战宝典 #26】止损与回撤控制手册:移动止损、最大回撤(Python 可跑)
python·1024程序员节·股票数据api·股票数据api接口·股票api数据接口·股票量化数据api·股票量化数据接口
2501_944521591 小时前
Deepmerge 跨端三方库仓颉适配全流程
java·python·eclipse·github
Patrick在香港1 小时前
同一行 strftime,两台机器跑出两种日期
python·datetime·时区·locale·日期处理
2601_967987371 小时前
用Python+OpenCV+YOLO写个游戏脚本:从自动瞄准到自动采集的保姆级教程
python·opencv·yolo·目标检测·游戏自动化
meiying88381 小时前
快递单号批量查询Python脚本:从手动到自动化的完整实现
开发语言·python·自动化
人工智能导论实践课2 小时前
【GUI桌面开发3】PyCharm配置外部工具
ide·python·pycharm
一千柯橘2 小时前
LangChain 的实时输出处理: stream_events 和 Streaming
python·langchain·agent
贾公子2 小时前
图片 AIGC 检测接入实战——URL 与 Base64 的取舍、体积校验与「你送过去的可能不是那张图」
python·aigc
SEO_juper2 小时前
Node.js 重定向链检测工具:301 跳了几跳、有没有成环,一次看清
xml·开发语言·python·node.js·json·bash