setNoData.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:python_scripting_for_spatial_data_processing 作者: upsdeepak 项目源码 文件源码
def setNoData(inputFile, noDataVal):
    # Open the image file, in update mode
    # so that the image can be edited.
    dataset = gdal.Open(inputFile, gdal.GA_Update)
    # Check that the image has been opened.
    if not dataset is None:
        # Iterate throughout the image bands
        # Note. i starts at 0 while the
        # band count in GDAL at 1.
        for i in range(dataset.RasterCount):
            # Print information to the user on what is
            # being set.
            print("Setting No Data (" + str(noDataVal) +") for band " + str(i+1))
            # Get the image band
            # the i+1 is because GDAL bands
            # start with 1
            band = dataset.GetRasterBand(i+1)
            # Set the no data value
            band.SetNoDataValue(noDataVal)
    else:
        # Print an error message if the file
        # could not be oppened
        print("Could not open the input image file: ", inputFile)


# This is the first part of the script to
# be executed
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号