<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Ahmet,<br>
    <br>
    I think it is about the same question as I earlier answered for
    Juli. I'm copy pasting it here, hope it helps:<br>
    You have to adapt it to your own circumstances ofcourse, but at the
    same time I'd encourage you to read the documentation because it has
    samples included.<br>
    ---------------<br>
    Try to split your functionality with the help of 'WITH' statements
    and see if you can do the grouping in that way in a subselect.<br>
    Something like:<br>
    <br>
    WITH clips AS (<br>
        SELECT p.ecoregion_cod, ST_Union(ST_Clip(r.rast,1, p.geom,
    true)) AS rast<br>
        FROM gis_wd.wd_ecoregiones AS p, rastertmp.prova AS r<br>
        WHERE ST_Intersects(r.rast, p.geom) <br>
        GROUP BY ecoregion_cod --now you don't have to group by the
    raster result itself<br>
    )<br>
    SELECT p.ecoregion_co, (ST_SummaryStats(rast, 1)).* FROM clips
    --this should give you the stats per ecoregion_co<br>
    <div class="moz-cite-prefix"><br>
      ---------------------------<br>
      <br>
      Best,<br>
       Tom<br>
      <br>
      On 7/31/2015 6:35 PM, Kishore raju wrote:<br>
    </div>
    <blockquote
cite="mid:CA+t-ap3=tk_3VwMoBnt-fh1po7uBH_x=c0CBHhMv3oUvfPEY-g@mail.gmail.com"
      type="cite">
      <div dir="ltr">I am trying to get pixels intersected in raster
        layer with polygons in vector layer. can you please help me in
        designing the query.<br>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Wed, Jul 29, 2015 at 5:26 PM, Tom
          van Tilburg <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:tom.van.tilburg@gmail.com" target="_blank">tom.van.tilburg@gmail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000"> Hi Ahmet,<br>
              <br>
              It depends on how you would like to have the values
              returned.<br>
              If it's an average (or some other kind of statistics) I
              think you need a two step approach:<br>
              <br>
              1) Clip the raster where it intersects with the polygon:<br>
                  <a moz-do-not-send="true"
                href="http://postgis.net/docs/RT_ST_Clip.html"
                target="_blank">http://postgis.net/docs/RT_ST_Clip.html</a><br>
              <br>
              2) Do you stats on the resulting clipped image:<br>
                  <a moz-do-not-send="true"
                href="http://postgis.net/docs/RT_ST_SummaryStats.html"
                target="_blank">http://postgis.net/docs/RT_ST_SummaryStats.html</a><br>
              <br>
              Hope this helps,<br>
                  Tom
              <div>
                <div class="h5"><br>
                  <br>
                  <div>On 7/27/2015 4:16 PM, Ahmet Temiz wrote:<br>
                  </div>
                </div>
              </div>
              <blockquote type="cite">
                <div>
                  <div class="h5">
                    <div dir="ltr">
                      <div class="gmail_default" style="font-size:small"> Hello,</div>
                      <div class="gmail_default" style="font-size:small"><br>
                      </div>
                      <div class="gmail_default" style="font-size:small">How
                        can we get raster values of a map that
                        intersects with certian part of a polygon map ?</div>
                      <div class="gmail_default" style="font-size:small"><br>
                      </div>
                      <div class="gmail_default" style="font-size:small"> regards</div>
                      <div><br>
                      </div>
                      -- <br>
                      <div>
                        <div dir="ltr">
                          <div>
                            <div dir="ltr">
                              <div>Ahmet Temiz<br>
                                Jeoloji Müh.<br>
                                Afet ve Acil Durum Yönetimi Başkanlığı<br>
                                Bilgi İşlem  Dairesi Başkanlığı-CBS
                                Grubu<br>
                                <br>
                                <br>
                                ________________________<br>
                                <br>
                                Ahmet Temiz<br>
                                Geological Eng.<br>
                                Information Systems - GIS Group<br>
                                Disaster and Emergency Management<br>
                                of Presidency</div>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                    <br>
                    <fieldset></fieldset>
                    <br>
                  </div>
                </div>
                <pre>_______________________________________________
postgis-users mailing list
<a moz-do-not-send="true" href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a>
<a moz-do-not-send="true" href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a></pre>
              </blockquote>
              <br>
            </div>
            <br>
            _______________________________________________<br>
            postgis-users mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
            <a moz-do-not-send="true"
              href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users"
              rel="noreferrer" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <br>
        -- <br>
        <div class="gmail_signature">
          <div dir="ltr">
            <div>
              <div dir="ltr">
                <div>
                  <div dir="ltr">
                    <div style="font-size:small"><font color="#cc0000"
                        face="monospace, monospace"><b>with regards</b></font></div>
                    <div style="font-size:small"><font face="monospace,
                        monospace"><br>
                      </font></div>
                    <div><font style="background-color:rgb(255,255,255)"
                        color="#0000ff" face="monospace, monospace"
                        size="2"><b>K. Kishore Raju</b></font></div>
                    <div><font face="monospace, monospace"><font
                          style="background-color:rgb(255,255,255)"
                          color="#0000ff"><font size="1"><b>           
                                  </b><i>BE,</i></font></font><span
                          style="color:rgb(0,0,255)"><font size="1"><i> ME,M.Tech,(Ph.D).</i></font></span></font></div>
                    <div><font style="background-color:rgb(255,255,255)"
                        size="1"><b><font color="#ff00ff"
                            face="monospace, monospace">Asst. Professor
                            IT Dept,</font></b></font></div>
                    <div><font style="background-color:rgb(255,255,255)"
                        face="monospace, monospace" size="1"><b><span
                            style="color:rgb(0,0,255)">S.R.K.R Engg.
                            College,</span></b></font></div>
                    <div><font style="background-color:rgb(255,255,255)"
                        face="monospace, monospace" size="1"><b><font
                            color="#0000ff">Bhimavaram</font><font
                            color="#000000">, </font><font
                            color="#ff0000">W.G.Dt</font><font
                            color="#000000">, </font></b></font></div>
                    <div><font style="background-color:rgb(255,255,255)"
                        size="1"><b><font color="#000000"
                            face="monospace, monospace">AP,India-534202</font></b></font></div>
                    <div><font style="background-color:rgb(255,255,255)"
                        face="monospace, monospace" size="1"><b><font
                            color="#ff00ff">Contact No: </font><font
                            color="#073763">09949844004</font></b></font></div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a></pre>
    </blockquote>
    <br>
  </body>
</html>