[postgis-users] raster, stats conditioned to a set of values

juli g. pausas juli.g.pausas at uv.es
Mon Jun 29 09:48:33 PDT 2015


Hi all
I'm just starting to discover postgis, it is really useful.
I have a raster file with different bands, that I have imported to postgres
(raster2pgsql, without the -R option, i.e., insite the database). I would
like to extract information from band 1, but filtering the data using only
1) pixels with positive values (in that band, band 1)
2) and pixels in which band 2 is equal to a given value, e.g. 1

The type of analysis I'd like to do is descriptive stats but also
intersecting with a vector map. If my raster is rastertmp.ndvitmp, two
examples are:

SELECT (ST_SummaryStats(rast, 1)).* FROM rastertmp.ndvitmp WHERE rid = 1


SELECT p.region_cod, ST_ValueCount(ST_Clip(r.rast,1, p.geom, true)) AS res
  FROM gis_wd.wd_regiones AS p, rastertmp.ndvitmp AS r
  WHERE ST_Intersects(r.rast, p.geom)
  AND p.region_cod = 'PA1214';


This works perfectly, but how can I compute the stats  only for pixels with
positive values and with a given value in another band?  The idea would be
something like:  WHERE ST_Values(rast, 1)>0 AND ST_Values(rast, 2)=1

Thanks for any help!

Juli
--
*CIDE, CSIC*  |  www.uv.es/jgpausas  |
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20150629/82b2f916/attachment.html>


More information about the postgis-users mailing list