Closed eshaan-joshi closed 4 years ago
AttributeError: 'NoneType' Object has no attribute 'GetRasterBand' Code block:
chm_dataset = gdal.Open(chm_file)
chm_raster = chm_dataset.GetRasterBand(1)
noDataVal_chm = chm_raster.GetNoDataValue()
cols_chm = chm_dataset.RasterXSize rows_chm = chm_dataset.RasterYSize bands_chm = chm_dataset.RasterCount mapinfo_chm =chm_dataset.GetGeoTransform() xMin = mapinfo_chm[0] yMax = mapinfo_chm[3] xMax = xMin + chm_dataset.RasterXSize/mapinfo_chm[1] yMin = yMax + chm_dataset.RasterYSize/mapinfo_chm[5] image_extent = (xMin,xMax,yMin,yMax)
AttributeError Traceback (most recent call last)
AttributeError: 'NoneType' Object has no attribute 'GetRasterBand' Code block:
Open the CHM file with GDAL
chm_dataset = gdal.Open(chm_file)
Get the raster band object
chm_raster = chm_dataset.GetRasterBand(1)
Get the NO DATA value
noDataVal_chm = chm_raster.GetNoDataValue()
Get required metadata from CHM file
cols_chm = chm_dataset.RasterXSize rows_chm = chm_dataset.RasterYSize bands_chm = chm_dataset.RasterCount mapinfo_chm =chm_dataset.GetGeoTransform() xMin = mapinfo_chm[0] yMax = mapinfo_chm[3] xMax = xMin + chm_dataset.RasterXSize/mapinfo_chm[1] yMin = yMax + chm_dataset.RasterYSize/mapinfo_chm[5] image_extent = (xMin,xMax,yMin,yMax)
Full Error Message:
AttributeError Traceback (most recent call last)