[postgis-users] How we get raster values

Tom van Tilburg tom.van.tilburg at gmail.com
Mon Aug 3 13:23:20 PDT 2015


Ahmet,

I think it is about the same question as I earlier answered for Juli. 
I'm copy pasting it here, hope it helps:
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.
---------------
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.
Something like:

WITH clips AS (
     SELECT p.ecoregion_cod, ST_Union(ST_Clip(r.rast,1, p.geom, true)) 
AS rast
     FROM gis_wd.wd_ecoregiones AS p, rastertmp.prova AS r
     WHERE ST_Intersects(r.rast, p.geom)
     GROUP BY ecoregion_cod --now you don't have to group by the raster 
result itself
)
SELECT p.ecoregion_co, (ST_SummaryStats(rast, 1)).* FROM clips --this 
should give you the stats per ecoregion_co

---------------------------

Best,
  Tom

On 7/31/2015 6:35 PM, Kishore raju wrote:
> I am trying to get pixels intersected in raster layer with polygons in 
> vector layer. can you please help me in designing the query.
>
> On Wed, Jul 29, 2015 at 5:26 PM, Tom van Tilburg 
> <tom.van.tilburg at gmail.com <mailto:tom.van.tilburg at gmail.com>> wrote:
>
>     Hi Ahmet,
>
>     It depends on how you would like to have the values returned.
>     If it's an average (or some other kind of statistics) I think you
>     need a two step approach:
>
>     1) Clip the raster where it intersects with the polygon:
>     http://postgis.net/docs/RT_ST_Clip.html
>
>     2) Do you stats on the resulting clipped image:
>     http://postgis.net/docs/RT_ST_SummaryStats.html
>
>     Hope this helps,
>         Tom
>
>
>     On 7/27/2015 4:16 PM, Ahmet Temiz wrote:
>>      Hello,
>>
>>     How can we get raster values of a map that intersects with
>>     certian part of a polygon map ?
>>
>>      regards
>>
>>     -- 
>>     Ahmet Temiz
>>     Jeoloji Müh.
>>     Afet ve Acil Durum Yönetimi Başkanlığı
>>     Bilgi İşlem  Dairesi Başkanlığı-CBS Grubu
>>
>>
>>     ________________________
>>
>>     Ahmet Temiz
>>     Geological Eng.
>>     Information Systems - GIS Group
>>     Disaster and Emergency Management
>>     of Presidency
>>
>>
>>     _______________________________________________
>>     postgis-users mailing list
>>     postgis-users at lists.osgeo.org  <mailto:postgis-users at lists.osgeo.org>
>>     http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
>
>     _______________________________________________
>     postgis-users mailing list
>     postgis-users at lists.osgeo.org <mailto:postgis-users at lists.osgeo.org>
>     http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
>
>
>
> -- 
> *with regards*
>
> *K. Kishore Raju*
> **/BE,// ME,M.Tech,(Ph.D)./
> *Asst. Professor IT Dept,*
> *S.R.K.R Engg. College,*
> *Bhimavaram, W.G.Dt, *
> *AP,India-534202*
> *Contact No: 09949844004*
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20150803/dc82f9c6/attachment.html>


More information about the postgis-users mailing list