renumber.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /****************************************************************************
  2. *
  3. * MODULE: r.cross
  4. *
  5. * AUTHOR(S): Michael Shapiro - CERL
  6. *
  7. * PURPOSE: Creates a cross product of the category values from
  8. * multiple raster map layers.
  9. *
  10. * COPYRIGHT: (C) 2006 by the GRASS Development Team
  11. *
  12. * This program is free software under the GNU General Public
  13. * License (>=v2). Read the file COPYING that comes with GRASS
  14. * for details.
  15. *
  16. ***************************************************************************/
  17. #include <stdlib.h>
  18. #include "glob.h"
  19. #include "local_proto.h"
  20. #include <grass/raster.h>
  21. #include <grass/glocale.h>
  22. int renumber(int in, int out)
  23. {
  24. CELL *cell, *c;
  25. int row, col;
  26. cell = Rast_allocate_c_buf();
  27. G_message(_("%s: STEP 3 ... "), G_program_name());
  28. for (row = 0; row < nrows; row++) {
  29. G_percent(row, nrows, 5);
  30. Rast_get_c_row(in, c = cell, row);
  31. col = ncols;
  32. while (col-- > 0) {
  33. if (!Rast_is_c_null_value(c))
  34. *c = table[*c];
  35. c++;
  36. }
  37. Rast_put_row(out, cell, CELL_TYPE);
  38. }
  39. G_percent(row, nrows, 10);
  40. G_free(cell);
  41. return 0;
  42. }