But try SELECT ST_Centroid((ST_PixelAsPolygons(ST_Reclass(rast))).geom) FROM yourRaster
and let us know the difference in terms of performance... You could be surprised! Pierre > -----Original Message----- > From: postgis-users-boun...@postgis.refractions.net [mailto:postgis-users- > boun...@postgis.refractions.net] On Behalf Of e.j.h.polle > Sent: Monday, June 25, 2012 5:34 PM > To: postgis-us...@googlegroups.com > Cc: PostGIS Users Discussion > Subject: Re: [postgis-users] Finding highest cell value in raster using > ST_Value > > Hi Bborie, Pierre, > > > Thanks for adding the ticket. (http://trac.osgeo.org/postgis/ticket/1889) > > And I guess I am looking forward to PostGIS 2.1 then :-) (But I am still a > little > proud of my 'round-about way' to locate the cell with the highest value...) > > Cheers, > > > Egge-Jan > > > Op maandag 25 juni 2012 21:39:29 UTC+1 schreef Bborie Park het volgende: > > Too many columns. I was thinking that this is better served in a > separate function as that value could be repeated. I'm adding a ticket > for that separate function. > > On 06/25/2012 01:36 PM, Pierre Racine wrote: > > Good find Bborie! > > > > I would add that we should fill a ticket like "ST_Summary should > report > the x and y raster coordinates of the max and the min". So four new columns... > > > > Pierre > > > >> -----Original Message----- > >> From: postgis-users-boun...@postgis.refractions.net > <mailto:postgis-users-boun...@postgis.refractions.net> [mailto:postgis-users- > >> boun...@postgis.refractions.net > <mailto:boun...@postgis.refractions.net> ] On Behalf Of Bborie Park > >> Sent: Monday, June 25, 2012 4:32 PM > >> To: postgis-users@postgis.refractions.net <mailto:postgis- > us...@postgis.refractions.net> > >> Subject: Re: [postgis-users] Finding highest cell value in raster > using > ST_Value > >> > >> Egge-Jan, > >> > >> That is an intriguing question with no clean/simple solution. The > >> fastest approach may be to call ST_Reclass() to create a 1BB mask > based > >> upon that value and the pass the resulting raster to > >> ST_PixelAsPolygons() which will give you what you want. > >> > >> Yes, the above is a round-about way to do this. This is something > I'll > >> (ST_PixelofValue?) see about adding for PostGIS 2.1. > >> > >> -bborie > >> > >> On 06/25/2012 01:16 PM, e.j.h.polle wrote: > >>> Hi, > >>> > >>> OK - with ST_SummaryStats it is easy to retrieve the highest value > in > the > >>> raster, but then I only have this value. Now I want to retrieve > >>> (information about) the cell/pixel having this value, to be able to > >>> visualize the highest point on the map. My original query (see first > post) > >>> does give me this information (after 45 seconds...). > >>> > >>> How would I go about to get hold of the pixel with the highest > value, > >>> knowing this value? > >>> > >>> Cheers, > >>> > >>> Egge-Jan > >>> > >>> On Sunday, June 24, 2012 8:47:58 PM UTC+1, DavidRA wrote: > >>>> > >>>> Why don't you use ST_SummaryStats instead ST_Value? That way > you can get > >>>> easily any basic stat, included the maximum value of the raster. It > would > >>>> be > >>>> something like: > >>>> > >>>> SELECT (ST_SummaryStats(rast)).max FROM raster_table; > >>>> > >>>> -- > >>>> View this message in context: > >>>> http://postgis.17.n6.nabble.com/Finding-highest-cell-value-in- > raster-using- <http://postgis.17.n6.nabble.com/Finding-highest-cell-value-in- > raster-using-> > >> ST-Value-tp4998545p4998554.html > >>>> Sent from the PostGIS - User mailing list archive at Nabble.com. > >>>> _______________________________________________ > >>>> postgis-users mailing list > >>>> postgis-users@postgis.refractions.net <mailto:postgis- > us...@postgis.refractions.net> > >>>> http://postgis.refractions.net/mailman/listinfo/postgis-users > <http://postgis.refractions.net/mailman/listinfo/postgis-users> > >>>> > >>> > >>> On Sunday, June 24, 2012 8:47:58 PM UTC+1, DavidRA wrote: > >>>> > >>>> Why don't you use ST_SummaryStats instead ST_Value? That way > you can get > >>>> easily any basic stat, included the maximum value of the raster. It > would > >>>> be > >>>> something like: > >>>> > >>>> SELECT (ST_SummaryStats(rast)).max FROM raster_table; > >>>> > >>>> -- > >>>> View this message in context: > >>>> http://postgis.17.n6.nabble.com/Finding-highest-cell-value-in- > raster-using- <http://postgis.17.n6.nabble.com/Finding-highest-cell-value-in- > raster-using-> > >> ST-Value-tp4998545p4998554.html > >>>> Sent from the PostGIS - User mailing list archive at Nabble.com. > >>>> _______________________________________________ > >>>> postgis-users mailing list > >>>> postgis-users@postgis.refractions.net <mailto:postgis- > us...@postgis.refractions.net> > >>>> http://postgis.refractions.net/mailman/listinfo/postgis-users > <http://postgis.refractions.net/mailman/listinfo/postgis-users> > >>>> > >>> > >>> On Sunday, June 24, 2012 8:47:58 PM UTC+1, DavidRA wrote: > >>>> > >>>> Why don't you use ST_SummaryStats instead ST_Value? That way > you can get > >>>> easily any basic stat, included the maximum value of the raster. It > would > >>>> be > >>>> something like: > >>>> > >>>> SELECT (ST_SummaryStats(rast)).max FROM raster_table; > >>>> > >>>> -- > >>>> View this message in context: > >>>> http://postgis.17.n6.nabble.com/Finding-highest-cell-value-in- > raster-using- <http://postgis.17.n6.nabble.com/Finding-highest-cell-value-in- > raster-using-> > >> ST-Value-tp4998545p4998554.html > >>>> Sent from the PostGIS - User mailing list archive at Nabble.com. > >>>> _______________________________________________ > >>>> postgis-users mailing list > >>>> postgis-users@postgis.refractions.net <mailto:postgis- > us...@postgis.refractions.net> > >>>> http://postgis.refractions.net/mailman/listinfo/postgis-users > <http://postgis.refractions.net/mailman/listinfo/postgis-users> > >>>> > >>> > >>> > >>> > >>> _______________________________________________ > >>> postgis-users mailing list > >>> postgis-users@postgis.refractions.net <mailto:postgis- > us...@postgis.refractions.net> > >>> http://postgis.refractions.net/mailman/listinfo/postgis-users > <http://postgis.refractions.net/mailman/listinfo/postgis-users> > >> > >> -- > >> Bborie Park > >> Programmer > >> Center for Vectorborne Diseases > >> UC Davis > >> 530-752-8380 > >> bkp...@ucdavis.edu > >> _______________________________________________ > >> postgis-users mailing list > >> postgis-users@postgis.refractions.net <mailto:postgis- > us...@postgis.refractions.net> > >> http://postgis.refractions.net/mailman/listinfo/postgis-users > <http://postgis.refractions.net/mailman/listinfo/postgis-users> > > _______________________________________________ > > postgis-users mailing list > > postgis-users@postgis.refractions.net <mailto:postgis- > us...@postgis.refractions.net> > > http://postgis.refractions.net/mailman/listinfo/postgis-users > <http://postgis.refractions.net/mailman/listinfo/postgis-users> > > > > -- > Bborie Park > Programmer > Center for Vectorborne Diseases > UC Davis > 530-752-8380 > bkp...@ucdavis.edu > _______________________________________________ > postgis-users mailing list > postgis-users@postgis.refractions.net <mailto:postgis- > us...@postgis.refractions.net> > http://postgis.refractions.net/mailman/listinfo/postgis-users > <http://postgis.refractions.net/mailman/listinfo/postgis-users> > _______________________________________________ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users