[postgis-users] Raster SQL to separate high value areas

liglio at pobox.com liglio at pobox.com
Tue Mar 8 12:09:33 PST 2016



I am trying to separate areas of high value of lightning probability (above
70%) in a Raster and calculate their centroids. I successfully loaded a
GeoTiff raster image (one band, gray scale, 982x1108 pixels) in PostgreSQL
9.5 (Postgis 2.2.1). I see the SQL results in OenJump 1.9.


I used the next SQL, but the function ST_PixelAsPoints result in a 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 displacement. Can I do without this
transformation raster-geometry ?




SELECT row_number() over () AS id,


  gc AS geom_collection,

  ST_Centroid(gc) AS centroid


  SELECT unnest(ST_ClusterWithin(geom, 0.1)) AS gc

  FROM (SELECT (ST_PixelAsPoints(rast, 1)).* 

    FROM tb_lightningprob) foo

    WHERE val > 0.7

) f;



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

More information about the postgis-users mailing list