code: def addRoughnessMapFromLandUse(self, name,
                                           session,
                                           land_use_grid,
                                           land_use_to_roughness_table=None,
                                           land_use_grid_id=None,
                                           ):
          LAND_USE_GRID_TABLES = {
                                   'nga'  : 'land_cover_nga.txt',
                                   'glcf' : 'land_cover_glcf_modis.txt',
                                   'nlcd' : 'land_cover_nlcd.txt',
                                  }
          if isinstance(land_use_to_roughness_table, pd.DataFrame):
              df = land_use_to_roughness_table
          else:
              if land_use_to_roughness_table is None:
                  if land_use_grid_id is None:
                      raise ValueError("Must have land_use_to_roughness_table or land_use_grid_id set ...")
                  land_use_to_roughness_table = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                                             '..', 'grid',
                                                             'land_cover',
                                                             LAND_USE_GRID_TABLES[land_use_grid_id])
              land_use_to_roughness_table = os.path.abspath(land_use_to_roughness_table)
              df = pd.read_table(land_use_to_roughness_table, delim_whitespace=True,
                                 header=None, skiprows=1,
                                 names=('id', 'description', 'roughness'),
                                 dtype={'id':'int', 'description':'str', 'roughness':'float'},
                                 )
          land_use_grid = os.path.abspath(land_use_grid)
          land_use_resampled = resample_grid(land_use_grid,
                                             self.projectFile.getGrid(),
                                             resample_method=gdalconst.GRA_NearestNeighbour,
                                             as_gdal_grid=True)
          unique_land_use_ids = np.unique(land_use_resampled.np_array())
          df = df[df.id.isin(unique_land_use_ids)]
          for land_use_id in unique_land_use_ids:
              if land_use_id not in df.id.values:
                  raise IndexError("Land use ID {0} not found in table.".format(land_use_id))
          self.deleteMapTable("ROUGHNESS", session)
          mapTable = MapTable(name="ROUGHNESS",
                              numIDs=len(df.index),
                              maxNumCells=0,
                              numSed=0,
                              numContam=0)
          indexMap = IndexMap(name=name)
          indexMap.mapTableFile = self
          mapTable.indexMap = indexMap
          mapTable.mapTableFile = self
          for row in df.itertuples():
              idx = MTIndex(str(row.id), row.description, '')
              idx.indexMap = indexMap
              val = MTValue('ROUGH', row.roughness)
              val.index = idx
              val.mapTable = mapTable
          manningn_card = self.projectFile.getCard('MANNING_N')
          if manningn_card:
              session.delete(manningn_card)
              session.commit()
          mapTable.indexMap.filename = '{0}.idx'.format(name)
          with tmp_chdir(self.projectFile.project_directory):
              land_use_resampled.to_grass_ascii(mapTable.indexMap.filename,
                                                print_nodata=False)
          if not self.projectFile.getCard('MAPPING_TABLE'):
              self.projectFile.setCard('MAPPING_TABLE',
                                       '{0}.cmt'.format(self.projectFile.name),
                                       add_quotes=True)