code: def get_ndv_b(b):
      
  
      b_ndv = b.GetNoDataValue()
      if b_ndv is None:
          #Check ul pixel for ndv
          ns = b.XSize
          nl = b.YSize
          ul = float(b.ReadAsArray(0, 0, 1, 1))
          #ur = float(b.ReadAsArray(ns-1, 0, 1, 1))
          lr = float(b.ReadAsArray(ns-1, nl-1, 1, 1))
          #ll = float(b.ReadAsArray(0, nl-1, 1, 1))
          #Probably better to use 3/4 corner criterion
          #if ul == ur == lr == ll:
          if np.isnan(ul) or ul == lr:
              b_ndv = ul
          else:
              #Assume ndv is 0
              b_ndv = 0
      elif np.isnan(b_ndv):
          b_dt = gdal.GetDataTypeName(b.DataType)
          if 'Float' in b_dt:
              b_ndv = np.nan
          else:
              b_ndv = 0
      return b_ndv
docs: Get NoData value for GDAL band.
  
      If NoDataValue is not set in the band, 
      extract upper left and lower right pixel values.
      Otherwise assume NoDataValue is 0.
   
      Parameters
      ----------
      b : GDALRasterBand object 
          This is the input band.
   
      Returns
      -------
      b_ndv : float 
          NoData value