<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Stefan,<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 31, 2015, at 9:37 AM, Stefan Kiefer <<a href="mailto:st_kiefer@web.de" class="">st_kiefer@web.de</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
  
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" class="">
  
  <div bgcolor="#FFFFFF" text="#000000" class="">
    Hi Nick,<br class="">
    back to office I was eager to try by myself. Actually it seems that
    the result of multiple AND or multiple layers - I didn't check this
    by now - results in values slightly lower 1 (e.g. 0.9995 in my
    case). And therefore maybe rounded to "0". What I have done is the
    folowing:<br class="">
    <br class=""></div></div></blockquote><div><br class=""></div><div><div>Thanks! I did try your suggestion and it provided me the results I was seeking of only showing the red routes:</div><div><br class=""></div><div>(1/("map@1" < 238 AND "map@1" > 210)) + (1/("map@2" < 123 AND "map@2" > 94)) + (1/("map@3" < 130 AND "map@3" > 98))</div><div><br class=""></div><div>Perhaps my math is fuzzy.  Why would the divisor resolve this situation whereas multiplier in following has problems?</div><div><br class=""></div><div>((“m@1" < 238 AND “m@1" > 210) * 1) * ((“m@2" < 123 AND “m@2" > 94) * 1) * ((“m@3" < 130 AND “m@3" > 98) * 1)</div><div><br class=""></div></div>The floating point values is a why I believe we have a rounding bug in Raster Calculator.  I suspect that during the calculation a number is converted to floating point, between 0 and 1 (eg 0.9995), and that causes the equation to result in all 0s.  Its unusual that the calculator is performing floating point math because these are all integer values being operated on by value comparison operators and other integer numbers without any division which would cause floating point conversion or multiplication by a floating point.  The numbers are all whole integers.  I was hoping the original author could chime in on the tool and perhaps this is a bug.</div><div><br class=""></div><div>I’m on Mac OSX using 2.10.1 release and see same results on 2.8 release.</div><div><br class=""></div><div>I’m suspecting this may be a bug related to:</div><div><br class=""></div><div>Raster calculator always returns float32 tiffs</div><div><a href="https://hub.qgis.org/issues/10965" class="">https://hub.qgis.org/issues/10965</a></div><div>Raster calculator produces only 0 values with conditional expression</div><div><a href="https://hub.qgis.org/issues/11682" class="">https://hub.qgis.org/issues/11682</a></div><div><br class=""></div><div>There is this suggestion on the mailing list of how to resolve, however am a bit confused on the methods.  The workaround may be to reproject the raster layer and I’m unsure why that’s required:</div><div><a href="http://lists.osgeo.org/pipermail/qgis-user/2014-November/029873.html" class="">http://lists.osgeo.org/pipermail/qgis-user/2014-November/029873.html</a></div><div><a href="http://lists.osgeo.org/pipermail/qgis-user/2014-November/029878.html" class="">http://lists.osgeo.org/pipermail/qgis-user/2014-November/029878.html</a></div><div><br class=""></div><div>Thanks again,</div><div>Nick</div><div><br class=""><blockquote type="cite" class=""><div class=""><div bgcolor="#FFFFFF" text="#000000" class="">
    <meta name="qrichtext" content="1" class=""><div style="margin: 0px; text-indent: 0px;" class=""><!--StartFragment-->(1/("pm2-5-europe-2001-2010@1">240
      AND
      "pm2-5-europe-2001-2010@1"<250))*(1/("pm2-5-europe-2001-2010@2">139
      AND "pm2-5-europe-2001-2010@2"<145)) *
      (1/("pm2-5-europe-2001-2010@3">80 AND
      "pm2-5-europe-2001-2010@3"<85))<br class="">
      <br class="">
    </div><div style="margin: 0px; text-indent: 0px;" class="">which
      results in a perfektly fitting mask of my pseudo demand.<br class="">
    </div><div style="margin: 0px; text-indent: 0px;" class="">Mayby you
      could verfy this with your data<br class="">
    </div><div style="margin: 0px; text-indent: 0px;" class=""><br class="">
      cheers<br class="">
      <!--EndFragment--></div>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">
    <style type="text/css" class="">
p, li { white-space: pre-wrap; }
</style><br class="">
    Stefan<br class="">
    <br class="">
    <div class="moz-cite-prefix">Am 31.07.2015 um 08:48 schrieb Stefan
      Kiefer:<br class="">
    </div>
    <blockquote cite="mid:1309030743.598358.1438325334696.JavaMail.open-xchange@omgreatgod.store" type="cite" class="">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" class="">
      <div class="">
        <div class="">Hi Nick,</div>
        <div class="">you are absolutely right. My thought was, that you get A
          layer with distinct values to identify the road. For a mask
          you are on the right way, and I either don't understand the
          behaviour except that you operate over three layers, which of
          course should work.</div>
        <div class="">Have you tryed to generate a composit of the three layers
          and mask the single values resulting for road structures?
          (it's more or less what I expected from my first approach.)</div>
        <div class=""> </div>
        <div class="">cheers</div>
        <div class=""> </div>
        <div class="">Stefan</div>
        <br class="">
        > Nick Papadonis <a class="moz-txt-link-rfc2396E" href="mailto:npapadonis@gmail.com"><npapadonis@gmail.com></a> hat am 31. Juli
        2015 um 08:31 geschrieben:<br class="">
        > <br class="">
        > <br class="">
        > Hi Stefan,<br class="">
        > <br class="">
        > It’s my understanding black has a value of 0 in the
        resulting layer.<br class="">
        > <br class="">
        > I tried this and it results in similar image to step (a)
        and also includes other colors at lower intensities mixed in
        with the red. The red has the highest intensity in the
        greyscale. I’m looking to create a binary image with just the
        colors of red in the palette I choose and using this trace
        vectors over the paths.<br class="">
        > <br class="">
        > Thanks,<br class="">
        > Nick<br class="">
        > <br class="">
        > > On Jul 31, 2015, at 2:04 AM, Stefan Kiefer
        <a class="moz-txt-link-rfc2396E" href="mailto:st_kiefer@web.de"><st_kiefer@web.de></a> wrote:<br class="">
        > > <br class="">
        > > Hi Nick,<br class="">
        > > I believe it is black bcause you always get a value of
        "1". Unfortunately I can not verify this, because I have no QGis
        by this moment. Most propably you wanted to calculate:<br class="">
        > > <br class="">
        > > (“m@1" < 238 AND “m@1" > 213 AND “m@2" < 123
        AND “m@2" > 98 AND “m@3" < 125 AND “m@3” > 99) *
        ((“m@1" < 238 AND “m@1" > 210) * "m@1") + ((“m@2" < 123
        AND “m@2" > 94) * “m@2") + ((“m@3" < 130 AND “m@3" >
        98) *“m@3"))<br class="">
        > > <br class="">
        > > cheers<br class="">
        > > <br class="">
        > > Stefan<br class="">
        > > <br class="">
        > > > Nick Papadonis <a class="moz-txt-link-rfc2396E" href="mailto:npapadonis@gmail.com"><npapadonis@gmail.com></a> hat
        am 31. Juli 2015 um 07:49 geschrieben:<br class="">
        > > > <br class="">
        > > > <br class="">
        > > > One more comment. The resulting layer histogram
        is showing the pixel range spread over frequency in floating
        point values. Is the raster calculator performing floating point
        math with potential rounding error?<br class="">
        > > > <br class="">
        > > > I found it also interesting that the following
        expression resulted in a layer, which when inspected for band
        values, has integer values of 2 and 3. 3 being the value I want
        for the red route.<br class="">
        > > > <br class="">
        > > > a) ((“m@1" < 238 AND “m@1" > 210) * 1) +
        ((“m@2" < 123 AND “m@2" > 94) * 1) + ((“m@3" < 130 AND
        “m@3" > 98) * 1) <br class="">
        > > > <br class="">
        > > > I then change the expression to only use values 2
        and greater and this shows properly:<br class="">
        > > > b) ((“m@1" < 238 AND “m@1" > 210) * 1) +
        ((“m@2" < 123 AND “m@2" > 94) * 1) + ((“m@3" < 130 AND
        “m@3" > 98) * 1) > 2<br class="">
        > > > <br class="">
        > > > I then changed the expression to ensure all three
        values are obtained and it results in a black image of 0’s. I
        was expecting only the red route to appear as it resulted in
        value of 3 in step (a). <br class="">
        > > > <br class="">
        > > > ((“m@1" < 238 AND “m@1" > 210) * 1) +
        ((“m@2" < 123 AND “m@2" > 94) * 1) + ((“m@3" < 130 AND
        “m@3" > 98) * 1) > 2.1<br class="">
        > > > ((“m@1" < 238 AND “m@1" > 210) * 1) +
        ((“m@2" < 123 AND “m@2" > 94) * 1) + ((“m@3" < 130 AND
        “m@3" > 98) * 1) >= 3<br class="">
        > > > <br class="">
        > > > I’m wondering how much testing the Raster
        Calculator has gone through and if there is a possible bug here.
        Perhaps something to do with floating point?<br class="">
        > > > <br class="">
        > > > Thanks again<br class="">
        > > > <br class="">
        > > > > On Jul 31, 2015, at 12:39 AM, Nick Papadonis
        <a class="moz-txt-link-rfc2396E" href="mailto:npapadonis@gmail.com"><npapadonis@gmail.com></a> wrote:<br class="">
        > > > > <br class="">
        > > > > Folks,<br class="">
        > > > > <br class="">
        > > > > I’m using QGIS 10.1. The following
        expressions result in a black raster of 0’s, when I expected
        only red pixels to appears in the binary image indicating routes
        on a map:<br class="">
        > > > > <br class="">
        > > > > a) (“m@1" < 238 AND “m@1" > 213 AND
        “m@2" < 123 AND “m@2" > 98 AND “m@3" < 125 AND “m@3”
        > 99) * 1<br class="">
        > > > > b) ((“m@1" < 238 AND “m@1" > 210) * 1)
        * ((“m@2" < 123 AND “m@2" > 94) * 1) * ((“m@3" < 130
        AND “m@3" > 98) * 1)<br class="">
        > > > > <br class="">
        > > > > I then tried the following individual
        expressions for each band as separate steps (sanity check) and
        they work to cover the pixels in range:<br class="">
        > > > > c) (“m@1" < 238 AND “m@1" > 213) * 1<br class="">
        > > > > d) (“m@2" < 123 AND “m@2" > 98) * 1<br class="">
        > > > > e) (“m@3" < 125 AND “m@3” > 99) * 1<br class="">
        > > > > <br class="">
        > > > > I then tried the following expression which
        appears to create a proper greyscale image focusing on the red
        pixels. I replaced the multiplication with addition to see what
        was happening:<br class="">
        > > > > f) ((“m@1" < 238 AND “m@1" > 210) * 1)
        + ((“m@2" < 123 AND “m@2" > 94) * 1) + ((“m@3" < 130
        AND “m@3" > 98) * 1)<br class="">
        > > > > <br class="">
        > > > > The resulting raster has a Min = 0 and Max =
        1.998. I was expecting it to be Min = 0 and Max = 3. The value
        of 3 would indicate all 3 bands were positive on color match. I
        then go to the layer properties and load calculate min/max again
        and it is Min = 0 and Max = 3. I tried to change the min/max
        settings on they layer and these settings will not stay set. The
        layer goes back to Max = 1.998. What’s even more odd is the max
        being a floating point number. I suspect that may be part of the
        issue. Anyone know why this is the case for integer band values?
        Has anyone successfully used the Raster Calculator to perform
        this sort of work before?<br class="">
        > > > > <br class="">
        > > > > Thanks again,<br class="">
        > > > > Nick<br class="">
        > > > <br class="">
        > > > _______________________________________________<br class="">
        > > > Qgis-user mailing list<br class="">
        > > > <a class="moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><br class="">
        > > > <a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br class="">
        > </div>
      <br class="">
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br class="">
      <pre wrap="" class="">_______________________________________________
Qgis-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a></pre>
    </blockquote>
    <br class="">
  </div>

_______________________________________________<br class="">Qgis-user mailing list<br class=""><a href="mailto:Qgis-user@lists.osgeo.org" class="">Qgis-user@lists.osgeo.org</a><br class="">http://lists.osgeo.org/mailman/listinfo/qgis-user</div></blockquote></div><br class=""></div></body></html>