gpt4 book ai didi

python - 栅格写入 GeoTiff 时缺少空间引用

转载 作者:太空宇宙 更新时间:2023-11-04 02:42:01 26 4
gpt4 key购买 nike

我正在尝试使用 rasterio 加载图像,修改 ndarray,然后使用与原始图像相同的空间引用系统写出。下面的函数是我尝试这样做的。但是输出的 geotiff 中缺少空间引用系统。对我做错了什么有什么建议吗?

我检查了输入的 geotiff crs 是否有效('epsg:32611')。

# Function to write out an ndarry as a GeoTIFF using the spatial references of a sample geotif file
def write_GeoTif_like(templet_tif_file, output_ndarry, output_tif_file):
import rasterio
orig = rasterio.open(templet_tif_file)
with rasterio.open(output_tif_file, 'w', driver='GTiff', height=output_ndarry.shape[0],
width=output_ndarry.shape[1], count=1, dtype=output_ndarry.dtype,
crs=orig.crs, transform=orig.transform, nodata=-9999) as dst:
dst.write(output_ndarry, 1)

最佳答案

以前被这个问题困扰过,我猜你的 GDAL_DATA 环境变量设置不正确(更多细节参见 https://github.com/conda/conda/issues/4050)。在不了解更多关于您的安装/操作系统的情况下,我不能肯定地说,但是如果 gdal(和 rasterio)无法找到元数据文件的位置,例如那些支持涉及坐标引用系统的操作,您将在输出 tif 中丢失 CRS。

关于python - 栅格写入 GeoTiff 时缺少空间引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46225675/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com