[GRASS-dev] weird bug(?) with r.mapcalc neighborhood modifier

Maris Nartiss maris.gis at gmail.com
Sun Feb 14 02:41:38 PST 2016


Nice catch, Moritz! There is a bug in neighbour modifier of mapcalc
(tested with 7.1 and 7.0).

I reported it as: https://trac.osgeo.org/grass/ticket/2917

A further analysis is required to find exact cause and all affected versions.

Māris.



2016-02-13 16:16 GMT+02:00 Moritz Lennert <mlennert at club.worldonline.be>:
> Hi,
>
> I'm not sure if this is a bug or just some feature of r.mapcalc that I don't
> really understand, so I'm posting here, not yet on track.
>
> I'm working on a module that calculate Moran's I for raster segments (i.e.
> clumps). For this I need to identify neighboring regions. I do that on a
> pixel-base, identifying in each direction of a given pixel those neighbors
> that have a different value than the current pixel.
>
> Here's an example of what I do, identifying neighbors lying below the
> current pixel:
>
> g.region n=224480.25 s=223910.25 w=635623 e=636449.5 res=28.5
> r.mapcalc "nd = if(landclass96[1,0]!=landclass96, landclass96[1,0], null())"
> r.stats -1n landclass96,nd sep=comma --q | awk -F, '{if($1==$2) print $0}'
> 5,5
> 5,5
> 1,1
> 1,1
> 5,5
>
> This r.stats result should not happen, IIUC: as I explicitly test for
> inequality in the r.mapcalc call, pixels should not have the same values in
> landclass96 and nd.
>
> The weird thing is this:
>
> r.mapcalc "nd_temp = landclass96[1,0]"
> r.mapcalc "nd2 = if(nd_temp!=landclass96, nd_temp, null())"
> r.stats -1n landclass96,nd2 sep=comma --q | awk -F, '{if($1==$2) print $0}'
> [empty result]
>
> i.e. by decomposing the r.mapcalc call into two separate calls, first
> identifying the below neighbor value of each pixel, then only keeping values
> for those pixels where that below neighbor value is different, everything
> works as expected.
>
> I'm I not using neighborhood modifiers as I should, or is this a bug ?
>
> Moritz
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev


More information about the grass-dev mailing list