c_count.c 523 B

12345678910111213141516171819202122232425262728293031
  1. #include <grass/gis.h>
  2. #include <grass/raster.h>
  3. void c_count(DCELL * result, DCELL * values, int n, const void *closure)
  4. {
  5. int count;
  6. int i;
  7. count = 0;
  8. for (i = 0; i < n; i++)
  9. if (!Rast_is_d_null_value(&values[i]))
  10. count++;
  11. *result = count;
  12. }
  13. void w_count(DCELL * result, DCELL(*values)[2], int n, const void *closure)
  14. {
  15. DCELL count;
  16. int i;
  17. count = 0.0;
  18. for (i = 0; i < n; i++)
  19. if (!Rast_is_d_null_value(&values[i][0]))
  20. count += values[i][1];
  21. *result = count;
  22. }