[GRASS-SVN] r72618 - grass/trunk/raster/r.kappa
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Apr 13 05:06:20 PDT 2018
Author: ychemin
Date: 2018-04-13 05:06:20 -0700 (Fri, 13 Apr 2018)
New Revision: 72618
Modified:
grass/trunk/raster/r.kappa/prt2csv_mat.c
Log:
Added class reporting to -m flag (matrix export)
Modified: grass/trunk/raster/r.kappa/prt2csv_mat.c
===================================================================
--- grass/trunk/raster/r.kappa/prt2csv_mat.c 2018-04-10 20:48:13 UTC (rev 72617)
+++ grass/trunk/raster/r.kappa/prt2csv_mat.c 2018-04-13 12:06:20 UTC (rev 72618)
@@ -24,6 +24,9 @@
const char *mapone;
FILE *fd;
+ long *cats;
+ char *cl;
+
if (output != NULL) {
if (hdr)
fd = fopen(output, "w");
@@ -87,19 +90,30 @@
/*fprintf(fd, "\t\t\t MAP1\n");*/
/* cat line */
fprintf(fd, "cat#\t");
- for (cndx = first_col; cndx < last_col; cndx++)
- fprintf(fd, "%ld\t", rlst[cndx]);
+ /* print labels MAP1*/
+ for (j = 0; j < ncat; j++) {
+ cats = rlst;
+ cl = Rast_get_c_cat((CELL *) &(cats[j]), &(layers[0].labels));
+ if (cl)
+ G_strip(cl);
+ if (cl == NULL || *cl == 0)
+ cl = "NULL";
+ fprintf(fd, "%s\t", cl);
+ }
+ //for (cndx = first_col; cndx < last_col; cndx++)
+ // fprintf(fd, "%ld\t", rlst[cndx]);
fprintf(fd, "RowSum");
fprintf(fd, "\n");
/* body of the matrix */
mapone = "MAP2";
for (rndx = 0; rndx < ncat; rndx++) {
- /*if (*(mapone) != '\0')
- fprintf(fd, " %c %5ld\t", *(mapone)++, rlst[rndx]);
- else
- fprintf(fd, " %5ld\t", rlst[rndx]);
- */
- fprintf(fd, "%5ld\t", rlst[rndx]);
+ cats = rlst;
+ cl = Rast_get_c_cat((CELL *) &(cats[rndx]),&(layers[1].labels));
+ if (cl)
+ G_strip(cl);
+ if (cl == NULL || *cl == 0)
+ cl = "NULL";
+ fprintf(fd, "%s\t", cl);
/* entries */
for (cndx = first_col; cndx < last_col; cndx++) {
thisone = (ncat * rndx) + cndx;
More information about the grass-commit
mailing list