code: def get_bareground_mask(bareground_ds, bareground_thresh=60, out_fn=None):
      
      print("Loading bareground")
      b = bareground_ds.GetRasterBand(1)
      l = b.ReadAsArray()
      print("Masking pixels with <%0.1f%% bare ground" % bareground_thresh)
      if bareground_thresh < 0.0 or bareground_thresh > 100.0:
          sys.exit("Invalid bare ground percentage")
      mask = (l>bareground_thresh)
      #Write out original data
      if out_fn is not None:
          print("Writing out %s" % out_fn)
          iolib.writeGTiff(l, out_fn, bareground_ds)
      l = None
      return mask
docs: Generate raster mask for exposed bare ground from global bareground data