~ubuntu-branches/ubuntu/wily/grass/wily

« back to all changes in this revision

Viewing changes to raster/r.statistics/o_skew.c

Tags: 7.0.0~rc1+ds1-1~exp1
* New upstream release candidate.
* Repack upstream tarball, remove precompiled Python objects.
* Add upstream metadata.
* Update gbp.conf and Vcs-Git URL to use the experimental branch.
* Update watch file for GRASS 7.0.
* Drop build dependencies for Tcl/Tk, add build dependencies:
  python-numpy, libnetcdf-dev, netcdf-bin, libblas-dev, liblapack-dev
* Update Vcs-Browser URL to use cgit instead of gitweb.
* Update paths to use grass70.
* Add configure options: --with-netcdf, --with-blas, --with-lapack,
  remove --with-tcltk-includes.
* Update patches for GRASS 7.
* Update copyright file, changes:
  - Update copyright years
  - Group files by license
  - Remove unused license sections
* Add patches for various typos.
* Fix desktop file with patch instead of d/rules.
* Use minimal dh rules.
* Bump Standards-Version to 3.9.6, no changes.
* Use dpkg-maintscript-helper to replace directories with symlinks.
  (closes: #776349)
* Update my email to use @debian.org address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
#include <stdlib.h>
4
4
#include <unistd.h>
5
5
#include <grass/gis.h>
 
6
#include <grass/raster.h>
6
7
#include <grass/glocale.h>
7
8
#include "method.h"
8
9
 
12
13
static int skew(double *, int, double *);
13
14
 
14
15
 
15
 
int
16
 
o_skew(char *basemap, char *covermap, char *outputmap, int usecats,
17
 
       struct Categories *cats)
 
16
int o_skew(const char *basemap, const char *covermap, const char *outputmap,
 
17
           int usecats, struct Categories *cats)
18
18
{
19
 
    char command[1024];
 
19
    struct Popen stats_child, reclass_child;
20
20
    FILE *stats, *reclass;
21
21
    int first, mem, i, count;
22
22
    long basecat, covercat, catb, catc;
27
27
    mem = MEM * sizeof(double);
28
28
    tab = (double *)G_malloc(mem);
29
29
 
30
 
    sprintf(command, "r.stats -cn input=\"%s,%s\" fs=space", basemap,
31
 
            covermap);
32
 
    stats = popen(command, "r");
33
 
 
34
 
    sprintf(command, "r.reclass i=\"%s\" o=\"%s\"", basemap, outputmap);
35
 
    reclass = popen(command, "w");
36
 
 
 
30
    stats = run_stats(&stats_child, basemap, covermap, "-cn");
 
31
    reclass = run_reclass(&reclass_child, basemap, outputmap);
37
32
 
38
33
    first = 1;
39
34
    while (read_stats(stats, &basecat, &covercat, &value)) {
54
49
        }
55
50
 
56
51
        if (usecats)
57
 
            sscanf(G_get_cat((CELL) covercat, cats), "%lf", &x);
 
52
            sscanf(Rast_get_c_cat((CELL *) &covercat, cats), "%lf", &x);
58
53
        else
59
54
            x = covercat;
60
55
 
75
70
    skew(tab, count, &var);
76
71
    fprintf(reclass, "%ld = %ld %f\n", catb, catb, var);
77
72
 
 
73
    G_popen_close(&stats_child);
 
74
    G_popen_close(&reclass_child);
78
75
 
79
 
    pclose(stats);
80
 
    pclose(reclass);
81
 
     /**/ return (0);
 
76
    return 0;
82
77
}
83
78
 
84
 
 
85
79
/***********************************************************************
86
80
*
87
81
*  Given an array of data[1...n], this routine returns its skewness