<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Thanks for the response.  A follow up question:  what if the
yourLongitude, yourLatitude values provided in the query are not grid
points in that they fall within a bounding pixel grid.  Only values for
the intersection points are known so how does a non-intersecting point
get assigned a value from the query?<br>
<br>
<img src="cid:part1.00080805.05000301@cpi.com" alt=""><br>
<br>
On 10/14/2011 3:32 PM, Pierre Racine wrote:
<blockquote
 cite="mid:87A96661E65C5541AB4D20721C2DD7F8CFB639AB11@EXCH-MBX-A.ulaval.ca"
 type="cite">
  <pre wrap="">If you want to get the pixel value under a point just do:

SELECT ST_Value(rast, ST_Transform(ST_SetSRID(ST_Point(yourLongitude, yourLatitude), 4326),  ST_SRID(rast))
FROM yourTable

That should be pretty fast.

In any case you should load your raster when loading it (-k100x100 or -k 20x20) and then index it:

CREATE INDEX srtm_tiled_rast_gist_idx  ON srtm_tiled USING GIST (ST_ConvexHull(rast));

Interpolating the elevation of a point is another story. You could build a grid of 8, 15 or 24 points around your lat/long, query the elevation at those points and use your algorithm to compute the interpolation.

Really getting the elevation for 1 or 25 points should be a matter of microseconds.

Pierre

  </pre>
  <blockquote type="cite">
    <pre wrap="">-----Original Message-----
From: <a class="moz-txt-link-abbreviated" href="mailto:postgis-users-bounces@postgis.refractions.net">postgis-users-bounces@postgis.refractions.net</a> [<a class="moz-txt-link-freetext" href="mailto:postgis-users">mailto:postgis-users</a>-
<a class="moz-txt-link-abbreviated" href="mailto:bounces@postgis.refractions.net">bounces@postgis.refractions.net</a>] On Behalf Of elliott
Sent: Thursday, October 13, 2011 9:38 AM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Retrieving Data from PostGIS Raster using ST_Value

The table contains SRTM3 data.  What I would really like to do is retrieve the
altitude for any given lat/lon.  We currently have scientific codes that read the
SRTM3 flat file into an array and interpolate the value for the lat/lon pair.  We
would like to retrieve the data from a database instead of flat file thinking the
performance would be better.  However, the times retrieving the array from the
database are many orders of magnitude worse than just reading the array in
from a flat file.

On 10/12/2011 8:34 PM, Pierre Racine wrote:
    </pre>
    <blockquote type="cite">
      <pre wrap="">If you want to get all the values for every pixel do:

SELECT (ST_DumpAsPolyogns(rast)).val
FROM your table

Can I ask why you want to do that? Normally people want to extract values
      </pre>
    </blockquote>
    <pre wrap="">intersecting with a polygon or a point.
    </pre>
    <blockquote type="cite">
      <pre wrap="">
You can also get the histogram of the raster using ST_Histogram().

Pierre
________________________________________
From: <a class="moz-txt-link-abbreviated" href="mailto:postgis-users-bounces@postgis.refractions.net">postgis-users-bounces@postgis.refractions.net</a>
[<a class="moz-txt-link-abbreviated" href="mailto:postgis-users-bounces@postgis.refractions.net">postgis-users-bounces@postgis.refractions.net</a>] On Behalf Of elliott
[<a class="moz-txt-link-abbreviated" href="mailto:elliott@cpi.com">elliott@cpi.com</a>]
Sent: Wednesday, October 12, 2011 9:04 AM
To: PostGIS Users Discussion
Subject: [postgis-users] Retrieving Data from PostGIS Raster using
ST_Value

Hello Everyone,

I am very new to using PostGIS Raster.  I need to retrieve data fields
from a tile loaded into the database.  Using ST_Height and ST_Width, I
get the number of rows and columns and iterate over these using the
ST_Value to retrieve the data.  This is extremely slow taking 1/2 hour
to get all of the data required.  Is there a faster way to accomplish this?

Thanks!
_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>
<a class="moz-txt-link-freetext" href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a>
_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>
<a class="moz-txt-link-freetext" href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a>


      </pre>
    </blockquote>
    <pre wrap="">
_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>
<a class="moz-txt-link-freetext" href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a>
    </pre>
  </blockquote>
  <pre wrap="">_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a>
<a class="moz-txt-link-freetext" href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a>

  </pre>
</blockquote>
<br>
</body>
</html>