<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Ahh, forgive stupid question: <o:p>
</o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">ST_Rescale flipped the sign of my y pixel size. Changing to ST_Rescale(rast_750, 375,-375) makes everything ducky.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Bryce<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> postgis-users [mailto:postgis-users-bounces@lists.osgeo.org]
<b>On Behalf Of </b>Nordgren, Bryce L -FS<br>
<b>Sent:</b> Thursday, March 10, 2016 12:00 PM<br>
<b>To:</b> PostGIS Users Discussion (postgis-users@lists.osgeo.org) <postgis-users@lists.osgeo.org><br>
<b>Subject:</b> [postgis-users] 2 raster map algebra returning all zeros<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I have a table with two raster columns, which I’m trying to combine into a third column using the two raster MapAlgebra. The columns represent fire events at different resolutions, which fortuitously are a simple factor of two different.
 These are all 8BUI rasters interpreted  as Boolean masks (0==False,1==True). The third column will eventually represent a logical OR of the two masks, at the higher resolution. Each row covers exactly the same extent at the different resolutions. Trying an
 expression which should simply copy from one raster into the result, I get: <o:p>
</o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">select rid, ST_ValueCount(rast_375,1.) as r375,
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">            ST_ValueCount(ST_Rescale(rast_750, 375.), 1.) as r750,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">            ST_ValueCount(ST_SetBandNoDataValue(ST_MapAlgebra(<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">                             rast_375, 1,
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">                             ST_Rescale(rast_750, 375.), 1,
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">                             '[rast2]',
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">                             '8BUI', 'FIRST'),3.),1.) as test
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">from "Run_0000".fire_events_raster
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">WHERE rast_375 is not null and rast_750 is not null ORDER BY r375 DESC;<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">rid  | r375 | r750 | test<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">------+------+------+------<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">  166 | 2448 | 1708 |    0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">  216 | 1044 | 1020 |    0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Courier New"">  916 | 1039 | 2068 |    0<o:p></o:p></span></p>
<p class="MsoNormal">…<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Running ST_SameAlignment() on the input rasters returns true across the board. They have the same upperleft corner. SRIDS are identical (96630; 
<a href="http://spatialreference.org/ref/sr-org/6630/">http://spatialreference.org/ref/sr-org/6630/</a>) If I use either input raster as both the first and second raster to MapAlgebra, I get output.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Any ideas what could be throwing MapAlgebra off? <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">Bryce<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><br>
<br>
<br>
<br>
This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil
 or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately.
<o:p></o:p></span></p>
</div>
</body>
</html>