<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 14 (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;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Monospaced;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EstiloDeEmail17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EstiloDeEmail18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.hps
        {mso-style-name:hps;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 3.0cm 70.85pt 3.0cm;}
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=PT-BR link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US>Hi,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>I am trying to separate areas of high value of lightning probability (above 70%) in a Raster<span style='color:#1F497D'> and calculate their centroids</span>. I successfully loaded a GeoTiff raster image (one band, gray scale, 982x1108 pixels) in PostgreSQL 9.5 (Postgis 2.2.1). I see the<span style='color:#1F497D'> SQL</span> result<span style='color:#1F497D'>s</span> in OenJump 1.9.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>I used </span><span lang=EN-US>the next SQL<span style='color:#1F497D'>, but the function </span></span><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>ST_PixelAsPoints result in a </span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:#2E2E2E'>geometry points which are of the pixel's upper-left corner. I am not sure that is the right way to do, because of that </span><span class=hps><span lang=EN style='font-family:"Arial","sans-serif";color:#222222'>displacement</span></span><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:#2E2E2E'>. Can I do without this transformation raster-geometry ?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='color:#1F497D'>Thanks.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:blue;mso-fareast-language:PT-BR'>SELECT </span></b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>row_number() over () </span><b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:blue;mso-fareast-language:PT-BR'>AS </span></b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>id,</span><span lang=EN-US style='font-size:12.0pt;font-family:Monospaced;mso-fareast-language:PT-BR'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>  ST_NumGeometries(gc),</span><span lang=EN-US style='font-size:12.0pt;font-family:Monospaced;mso-fareast-language:PT-BR'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>  gc </span><b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:blue;mso-fareast-language:PT-BR'>AS </span></b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>geom_collection,</span><span lang=EN-US style='font-size:12.0pt;font-family:Monospaced;mso-fareast-language:PT-BR'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>  ST_Centroid(gc) </span><b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:blue;mso-fareast-language:PT-BR'>AS </span></b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>centroid</span><span lang=EN-US style='font-size:12.0pt;font-family:Monospaced;mso-fareast-language:PT-BR'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:blue;mso-fareast-language:PT-BR'>FROM </span></b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>(</span><span lang=EN-US style='font-size:12.0pt;font-family:Monospaced;mso-fareast-language:PT-BR'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>  </span><b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:blue;mso-fareast-language:PT-BR'>SELECT unnest</span></b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>(ST_ClusterWithin(geom, </span><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:fuchsia;mso-fareast-language:PT-BR'>0</span><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>.</span><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:fuchsia;mso-fareast-language:PT-BR'>1</span><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>)) </span><b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:blue;mso-fareast-language:PT-BR'>AS </span></b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>gc</span><span lang=EN-US style='font-size:12.0pt;font-family:Monospaced;mso-fareast-language:PT-BR'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>  </span><b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:blue;mso-fareast-language:PT-BR'>FROM </span></b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>(</span><b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:blue;mso-fareast-language:PT-BR'>SELECT </span></b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>(ST_PixelAsPoints(rast, </span><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:fuchsia;mso-fareast-language:PT-BR'>1</span><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>)).* </span><span lang=EN-US style='font-size:12.0pt;font-family:Monospaced;mso-fareast-language:PT-BR'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>    </span><b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:blue;mso-fareast-language:PT-BR'>FROM </span></b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>tb_lightningprob) foo</span><span lang=EN-US style='font-size:12.0pt;font-family:Monospaced;mso-fareast-language:PT-BR'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>    </span><b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:blue;mso-fareast-language:PT-BR'>WHERE </span></b><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>val > </span><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:fuchsia;mso-fareast-language:PT-BR'>0</span><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>.</span><span lang=EN-US style='font-size:9.0pt;font-family:Monospaced;color:fuchsia;mso-fareast-language:PT-BR'>7</span><span lang=EN-US style='font-size:12.0pt;font-family:Monospaced;mso-fareast-language:PT-BR'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:9.0pt;font-family:Monospaced;color:black;mso-fareast-language:PT-BR'>) f;</span><span style='font-size:12.0pt;font-family:Monospaced;mso-fareast-language:PT-BR'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:12.0pt;font-family:Monospaced;mso-fareast-language:PT-BR'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p></div></body></html>