Hi Group,<br><br>I think I want your opinion on a query I have written.<br><br>The goal is to find the highest value in a DEM, a raster table. The solution I found brings me where I want to go, but it takes 45 seconds on a relatively small (225*259) grid. It looks like it is especially the nested loop on the ST_Value function in the subquery that does take some time.<br><br>Can you have a look at the query below and tell me if I am on the right track. Or is there an other route I should follow?<br><br>A full description of my workflow (and the origin of the table used) can be found in 2 blog posts:<br><ul><li>http://twiav-tt.blogspot.nl/2012/06/postgis-raster-analysis-find-highest.html</li><li>http://twiav-tt.blogspot.nl/2012/06/postgis-raster-analysis-find-highest_24.html</li></ul><p>This is the query:</p><p><font face="courier new,monospace">INSERT INTO france.highest_peak_martinique(height, geom)<br>SELECT  height, ST_SetSRID(ST_MakePoint(ST_Raster2WorldCoordX(rast,x),<br>ST_Raster2WorldCoordY(rast,y)),32620) as geom FROM<br>(SELECT ST_Value(rast, hor.n, ver.n) AS height, hor.n AS x, ver.n AS y<br>FROM generate_series(1,225) as hor(n), generate_series(1,259) as ver(n), france.mnt_martinique<br>ORDER BY height DESC LIMIT 1) AS highest_cell_value, france.mnt_martinique;<br></font></p><p><font face="arial,sans-serif">Please let me know what you think.</font></p><p><font face="arial,sans-serif">TIA,</font></p><p><font face="arial,sans-serif">Egge-Jan</font><br></p>