Re: [GRASS-user] compare a DCELL and FCELL question
ming han <[email protected]> Sun, 24 Jan 2021 09:51:08 -0500
| Newsgroups | gmane.comp.gis.grass.devel,gmane.comp.gis.grass.user |
|---|---|
| Message-ID | <CAD+uAWjCUF2T+D3qUYBgdhUjhCa9dc=wQ0mTbQO__utMsNyQ6Q@mail.gmail.com> |
--===============8410621477227656753==
Content-Type: multipart/alternative; boundary="000000000000d7c35405b9a68dfc"
--000000000000d7c35405b9a68dfc
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Hi Markus and Micha
I am just trying to find grids have the same values in these two
rasters, I will try the threshold approach.
Thanks
Ming
Markus Neteler <[email protected]> =E4=BA=8E2021=E5=B9=B41=E6=9C=8824=E6=97=
=A5=E5=91=A8=E6=97=A5 =E4=B8=8A=E5=8D=886:58=E5=86=99=E9=81=93=EF=BC=9A
> Hi Ming,
>
> On Sun, Jan 24, 2021 at 10:49 AM ming han <[email protected]> wrote:
> >
> > Hi Micha
> >
> > Many thanks for your reply.
> > Here is the command I am using:
> >
> > if(float(cat1_acc_riv) =3D=3D float(cat1_minacc), str_r, null())
> >
> > The str_r is a CELL raster. the result is different when I change
> it to:
> > if(int(cat1_acc_riv) =3D=3D int(cat1_minacc), str_r, null())
>
> Note that numerical "equality" is better tested with a threshold test
> against the map pixel difference.
> As the threshold, we use GRASS_EPSILON which is defined as 1.0e-15.
>
> Hence the test needs to be implemented in a different way, i.e. by
> using an epsilon.
> Essentially something like this:
>
> if(fabs(map_A - map_B) <=3D 1.0e-15, ... )
>
> In your case (untested):
> r.mapcalc diffepsilon =3D if( abs( map_A - map_B) <=3D 1.0e-15, str_r , n=
ull())
>
> See related discussions here: [1], [2] and elsewhere.
>
> [1] Comment by Glynn: https://trac.osgeo.org/grass/ticket/2854#comment:9
> [2] Comment by Glynn:
> https://lists.osgeo.org/pipermail/grass-user/2015-October/073200.html
>
> Best,
> Markus
>
--000000000000d7c35405b9a68dfc
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hi Markus and Micha<div><br></div><div>=C2=A0 =C2=A0 =C2=
=A0I am just trying to find grids have the same values in these two rasters=
, I will try the threshold=C2=A0approach.</div><div><br></div><div>Thanks</=
div><div>Ming=C2=A0</div></div><br><div class=3D"gmail_quote"><div dir=3D"l=
tr" class=3D"gmail_attr">Markus Neteler <<a href=3D"mailto:neteler@osgeo=
.org">[email protected]</a>> =E4=BA=8E2021=E5=B9=B41=E6=9C=8824=E6=97=A5=
=E5=91=A8=E6=97=A5 =E4=B8=8A=E5=8D=886:58=E5=86=99=E9=81=93=EF=BC=9A<br></d=
iv><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bord=
er-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Ming,<br>
<br>
On Sun, Jan 24, 2021 at 10:49 AM ming han <<a href=3D"mailto:dustming@gm=
ail.com" target=3D"_blank">[email protected]</a>> wrote:<br>
><br>
> Hi Micha<br>
><br>
>=C2=A0 =C2=A0 =C2=A0 Many thanks for your reply.<br>
>=C2=A0 =C2=A0 =C2=A0 Here is the command I am using:<br>
><br>
>=C2=A0 =C2=A0 =C2=A0 if(float(cat1_acc_riv) =3D=3D float(cat1_minacc), =
str_r, null())<br>
><br>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0The str_r is a CELL raster. the result is di=
fferent when I change it to:<br>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 if(int(cat1_acc_riv) =3D=3D int(cat1_minacc=
), str_r, null())<br>
<br>
Note that numerical "equality" is better tested with a threshold =
test<br>
against the map pixel difference.<br>
As the threshold, we use GRASS_EPSILON which is defined as 1.0e-15.<br>
<br>
Hence the test needs to be implemented in a different way, i.e. by<br>
using an epsilon.<br>
Essentially something like this:<br>
<br>
if(fabs(map_A - map_B) <=3D 1.0e-15, ... )<br>
<br>
In your case (untested):<br>
r.mapcalc diffepsilon =3D if( abs( map_A - map_B) <=3D 1.0e-15, str_r , =
null())<br>
<br>
See related discussions here: [1], [2] and elsewhere.<br>
<br>
[1] Comment by Glynn: <a href=3D"https://trac.osgeo.org/grass/ticket/2854#c=
omment:9" rel=3D"noreferrer" target=3D"_blank">https://trac.osgeo.org/grass=
/ticket/2854#comment:9</a><br>
[2] Comment by Glynn:<br>
<a href=3D"https://lists.osgeo.org/pipermail/grass-user/2015-October/073200=
.html" rel=3D"noreferrer" target=3D"_blank">https://lists.osgeo.org/piperma=
il/grass-user/2015-October/073200.html</a><br>
<br>
Best,<br>
Markus<br>
</blockquote></div>
--000000000000d7c35405b9a68dfc--
--===============8410621477227656753==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
grass-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/grass-dev
--===============8410621477227656753==--