[GRASS5] calculating averages on raster map patches?

Markus Neteler neteler at itc.it
Mon Aug 22 12:07:18 EDT 2005


Hi,

I have a floasting point EVI vegetation index map from MODIS and vector fields.
Now I need to calculate the average EVI value per field. To do so, I

- used v.to.rast to generate a raster fields map (each field one number)
- run r.average: segmentation fault because the underlying 'r.stats -anC '
  segfaults
- run r.statistics: doesn't support FCELL/DCELL


If you want to test with Spearfish:
g.region -dp
r.average -c base=fields cover=elevation.10m output=elev.by.farm
WARNING: r.stats: cats for elevation.10m are either missing or have no
         explicit labels. Using nsteps=255

         -> doesn't sound convincing either 


On a 64bit box I get a segfault from r.stats (called by r.average) after this
message:

gdb `which r.stats`
(gdb) r  -anC input='areecampione125m,modis_vi250m20010712.250m_16_days_EVI' fs=space
Program received signal SIGSEGV, Segmentation fault.
0x0000000000402c02 in main (argc=1, argv=0x3535323d737065) at main.c:242
242         for (i = 0; name = option.cell->answers[i]; i++)

(gdb) bt full
#0  0x0000000000402c02 in main (argc=1, argv=0x3535323d737065) at main.c:242
        msg = "r.stats: cats for modis_vi250m20010712.250m_16_days_EVI are either missing or have no explicit label"
        fd = (int *) 0x5090a0
        i = 2
        name = 0xe8 <Address 0xe8 out of bounds>
        mapset = 0x1 <Address 0x1 out of bounds>
        verbose = 1
        raw_data = 1575156072
        with_coordinates = 0
        with_xy = 0
        with_percents = 0
        with_counts = 0
        with_areas = 1
        with_labels = 0
        fmt = '\0' <repeats 19 times>
        range = {min = 1, max = 40, first_time = 0}
        fp_range = {min = -0.247, max = 1, first_time = 0}
        q = {truncate_only = 0, round_only = 0, defaultDRuleSet = 4199435, defaultCRuleSet = 0, infiniteLeftSet = 0,
  infiniteRightSet = 0, cRangeSet = 1569807600, maxNofRules = 0, nofRules = 0, defaultDMin = 2.7108496074642367e-312,
  defaultDMax = 1.2174480074876701e-316, defaultCMin = 4199435, defaultCMax = 0, infiniteDLeft = 0,
  infiniteDRight = 1.1111882213708365e-312, infiniteCLeft = -1786587576, infiniteCRight = 42, dMin = -0.247, dMax = 1, cMin = 1,
  cMax = 255, table = 0x50cdc0, fp_lookup = {vals = 0x3436, rules = 0x0, nalloc = 0, active = 0,
    inf_dmin = 9.0363127466918322e-313, inf_dmax = 1.1111936913593466e-312, inf_min = -1073744856, inf_max = 127}}
        min = 1
        max = 255
        null_set = 1
        dmin = -0.247
        dmax = 1
        module = (struct GModule *) 0xe8
        flag = {A = 0x5089d0, a = 0x508a20, c = 0x508a70, p = 0x508ac0, l = 0x508b10, q = 0x508b60, n = 0x508bb0, N = 0x508c00,
  one = 0x2a95705380, x = 0x508ca0, g = 0x508c50, i = 0x508d90, r = 0x508d40, C = 0x508cf0}
        option = {cell = 0x3535323d737065, fs = 0x508730, nv = 0x5087c0, output = 0x508850, nsteps = 0x508900}

Any ideas? I just wonder about

/* open all cell files */
    for (i = 0; name = option.cell->answers[i]; i++)
                    ^^^

Does anyone know how to get the desired result?
Can't believe that such a standard application fails... :-(

Markus




More information about the grass-dev mailing list