main.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. ************************************************************
  3. * MODULE: r.le.pixel/main.c *
  4. * Version 5.0 Nov. 1, 2001 *
  5. * *
  6. * AUTHOR: W.L. Baker, University of Wyoming *
  7. * BAKERWL@UWYO.EDU *
  8. * *
  9. * PURPOSE: To analyze pixel-scale landscape properties *
  10. * main.c calls user_input.c, then displays user *
  11. * choices, then calls the appropriate routine *
  12. * *
  13. * COPYRIGHT: (C) 2001 by W.L. Baker *
  14. * *
  15. * This program is free software under the GNU General *
  16. * Public License(>=v2). Read the file COPYING that comes *
  17. * with GRASS for details *
  18. * *
  19. ************************************************************/
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include <grass/config.h>
  24. #include <grass/gis.h>
  25. #include <grass/glocale.h>
  26. #include "pixel.h"
  27. struct CHOICE *choice;
  28. int main(int argc, char **argv)
  29. {
  30. struct GModule *module;
  31. /* initialize the GRASS GIS system */
  32. G_gisinit(argv[0]);
  33. /* allocate space for the choice data structure */
  34. choice = (struct CHOICE *)G_calloc(1, sizeof(struct CHOICE));
  35. module = G_define_module();
  36. G_add_keyword(_("raster"));
  37. module->description =
  38. _("Contains a set of measures for attributes, diversity, texture, "
  39. "juxtaposition, and edge.");
  40. /* call user_input to read in the parameters */
  41. user_input(argc, argv);
  42. /* display the parameter choices */
  43. fprintf(stdout, "\nPARAMETER CHOICES:\n");
  44. fprintf(stdout, "\tMAP:\t %s\n", choice->fn);
  45. if (choice->wrum == 'r')
  46. fprintf(stdout, "\tREGION:\t %s\n", choice->reg);
  47. fprintf(stdout, "\tSAMPLE:");
  48. if (choice->wrum == 'w')
  49. fprintf(stdout, "\t whole map \n");
  50. if (choice->wrum == 'm')
  51. fprintf(stdout, "\t moving window\n");
  52. if (choice->wrum == 'u')
  53. fprintf(stdout, "\t units \n");
  54. if (choice->wrum == 'r')
  55. fprintf(stdout, "\t regions \n");
  56. if (choice->edgemap || choice->units || choice->z)
  57. fprintf(stdout, "\tOUTPUT MAPS:\n");
  58. if (choice->edgemap)
  59. fprintf(stdout, "\t\t edge\n");
  60. if (choice->units)
  61. fprintf(stdout, "\t\t units_x\n");
  62. if (choice->z)
  63. fprintf(stdout, "\t\t zscores\n");
  64. if (choice->att[0]) {
  65. fprintf(stdout, "\tATTRIBUTE MEASURES:\n");
  66. if (choice->att[1])
  67. fprintf(stdout, "\t\t mean pixel attribute\n");
  68. if (choice->att[2])
  69. fprintf(stdout, "\t\t st. dev. pixel attribute\n");
  70. if (choice->att[3])
  71. fprintf(stdout, "\t\t minimum pixel attribute\n");
  72. if (choice->att[4])
  73. fprintf(stdout, "\t\t maximum pixel attribute\n");
  74. }
  75. if (choice->div[0]) {
  76. fprintf(stdout, "\tDIVERSITY MEASURES:\n");
  77. if (choice->div[1])
  78. fprintf(stdout, "\t\t richness\n");
  79. if (choice->div[2])
  80. fprintf(stdout, "\t\t Shannon\n");
  81. if (choice->div[3])
  82. fprintf(stdout, "\t\t dominance\n");
  83. if (choice->div[4])
  84. fprintf(stdout, "\t\t inverse Simpson\n");
  85. }
  86. if (choice->te2[0]) {
  87. fprintf(stdout, "\tTEXTURE METHOD:\n");
  88. if (choice->tex == 1)
  89. fprintf(stdout, "\t\t 2N-H\n");
  90. else if (choice->tex == 2)
  91. fprintf(stdout, "\t\t 2N-45\n");
  92. else if (choice->tex == 3)
  93. fprintf(stdout, "\t\t 2N-V\n");
  94. else if (choice->tex == 4)
  95. fprintf(stdout, "\t\t 2N-135\n");
  96. else if (choice->tex == 5)
  97. fprintf(stdout, "\t\t 4N-HV\n");
  98. else if (choice->tex == 6)
  99. fprintf(stdout, "\t\t 4N-DIAG\n");
  100. else if (choice->tex == 7)
  101. fprintf(stdout, "\t\t 8N\n");
  102. fprintf(stdout, "\tTEXTURE MEASURES:\n");
  103. if (choice->te2[1])
  104. fprintf(stdout, "\t\t contagion\n");
  105. if (choice->te2[2])
  106. fprintf(stdout, "\t\t ang. sec. mom.\n");
  107. if (choice->te2[3])
  108. fprintf(stdout, "\t\t inv. diff. mom.\n");
  109. if (choice->te2[4])
  110. fprintf(stdout, "\t\t entropy\n");
  111. if (choice->te2[5])
  112. fprintf(stdout, "\t\t contrast\n");
  113. }
  114. if (choice->jux[0]) {
  115. fprintf(stdout, "\tJUXTAPOSITION MEASURES:\n");
  116. if (choice->jux[1])
  117. fprintf(stdout, "\t\t mean juxtaposition\n");
  118. if (choice->jux[2])
  119. fprintf(stdout, "\t\t standard deviation of juxtaposition\n");
  120. }
  121. if (choice->edg[0]) {
  122. fprintf(stdout, "\tEDGE MEASURES:\n");
  123. if (choice->edg[1])
  124. fprintf(stdout, "\t\t sum of edges\n");
  125. if (choice->edg[2])
  126. fprintf(stdout, "\t\t sum of edges by type\n");
  127. }
  128. /* if not moving window, setup the
  129. r.le.out subdirectory */
  130. if (choice->wrum != 'm')
  131. G_mkdir("r.le.out");
  132. texture_fore();
  133. G_free(choice);
  134. return (EXIT_SUCCESS);
  135. }