main.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. G_add_keyword(_("topographic index"));
  38. module->description =
  39. _("Creates a topographic index (wetness index) raster map from an elevation raster map.");
  40. params.input = G_define_standard_option(G_OPT_R_ELEV);
  41. params.input->key = "input";
  42. params.output = G_define_standard_option(G_OPT_R_OUTPUT);
  43. params.output->description = _("Name for output topographic index raster map");
  44. if (G_parser(argc, argv))
  45. exit(EXIT_FAILURE);
  46. /* Make sure that the current projection is not lat/long */
  47. if (G_projection() == PROJECTION_LL)
  48. G_fatal_error(_("Lat/Long location is not supported by %s. Please reproject map first."),
  49. G_program_name());
  50. input = params.input->answer;
  51. output = params.output->answer;
  52. G_get_window(&window);
  53. read_cells();
  54. initialize();
  55. calculate_atanb();
  56. write_cells();
  57. exit(EXIT_SUCCESS);
  58. }