main.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /****************************************************************************
  2. *
  3. * MODULE: r.topidx
  4. *
  5. * AUTHOR(S): Huidae Cho <grass4u gmail.com>, Hydro Laboratory,
  6. * Kyungpook National University
  7. * Based on GRIDATB.FOR by Keith Beven <k.beven lancaster.ac.uk>
  8. *
  9. * PURPOSE: Creates a topographic index raster map from an elevation
  10. * raster map.
  11. *
  12. * COPYRIGHT: (C) 2000-2014 by the GRASS Development Team
  13. *
  14. * This program is free software under the GNU General Public
  15. * License (>=v2). Read the file COPYING that comes with GRASS
  16. * for details.
  17. *
  18. *****************************************************************************/
  19. #define _MAIN_C_
  20. #include <stdlib.h>
  21. #include <grass/gis.h>
  22. #include <grass/glocale.h>
  23. #include "global.h"
  24. int main(int argc, char **argv)
  25. {
  26. struct GModule *module;
  27. struct
  28. {
  29. struct Option *input;
  30. struct Option *output;
  31. } params;
  32. G_gisinit(argv[0]);
  33. module = G_define_module();
  34. G_add_keyword(_("raster"));
  35. G_add_keyword(_("hydrology"));
  36. G_add_keyword(_("wetness"));
  37. module->description =
  38. _("Creates a topographic index (wetness index) raster map from an elevation raster map.");
  39. params.input = G_define_standard_option(G_OPT_R_ELEV);
  40. params.input->key = "input";
  41. params.output = G_define_standard_option(G_OPT_R_OUTPUT);
  42. params.output->description = _("Name for output topographic index raster map");
  43. if (G_parser(argc, argv))
  44. exit(EXIT_FAILURE);
  45. /* Make sure that the current projection is not lat/long */
  46. if (G_projection() == PROJECTION_LL)
  47. G_fatal_error(_("Lat/Long location is not supported by %s. Please reproject map first."),
  48. G_program_name());
  49. input = params.input->answer;
  50. output = params.output->answer;
  51. G_get_window(&window);
  52. read_cells();
  53. initialize();
  54. calculate_atanb();
  55. write_cells();
  56. exit(EXIT_SUCCESS);
  57. }