【问题标题】:Spatial reference missing from rasterio write to GeoTiffrasterio 写入 GeoTiff 时缺少空间参考
【发布时间】:2018-02-23 19:49:10
【问题描述】:

我正在尝试使用 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)

【问题讨论】:

    标签: python image image-processing scipy rasterio


    【解决方案1】:

    之前被这个问题困扰过,我猜您的GDAL_DATA 环境变量设置不正确(有关详细信息,请参阅https://github.com/conda/conda/issues/4050)。在不了解您的安装/操作系统的情况下,我不能肯定地说,但如果gdal(和rasterio)无法找到包含元数据文件的位置,例如支持涉及坐标参考系统的操作的位置,您将失去输出 tif 中的 CRS。

    【讨论】:

    • 在 Windows 上并且未设置 GDAL_DATA。手动设置它。我很惊讶当没有设置 GDAL_DATA 时没有在光栅中引发警告。
    • 是的,这很好。我还没有研究过实现它会有多难。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-07
    • 2011-08-21
    • 2018-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多