genophenoenvo / keys

CyVerse summer internship project
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Jupyter Issue #2

Closed eshaan-joshi closed 4 years ago

eshaan-joshi commented 4 years ago

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)

in 3 4 #Get the raster band object ----> 5 chm_raster = chm_dataset.GetRasterBand(1) 6 7 #Get the NO DATA value AttributeError: 'NoneType' object has no attribute 'GetRasterBand' Comment I think this is a GDal issue