I'm new to PostGIS so hopefully this isn't a stupid question.
I'm using PostGIS 2.1 and loading it with SRTM rasters for the entire US using: raster2pgsql -s 4236 -I -C -M *.hgt -F public.elevation | psql -d srtm
I'm not tiling it (eg. -t 100x100) so the tiles are 1200x1200. I want to be able to query the dataset to get an elevation given a latitude / longitude. I've figured out how to do it but it queries all of the rasters instead of just the one that contains the the point. This is what I have:
SELECT ST_Value(rast, ST_Transform(ST_SetSRID(ST_Point(latitude,longitude), 4326), ST_SRID(rast)))
FROM public.elevation
I'd like to be able to constrain the query so that it only looks up the value from the raster that contains the latitude / longitude but I'm not quite sure how to do that. Something like this maybe
SELECT ST_Value(rast, ST_Transform(ST_SetSRID(ST_Point(latitude,longitude), 4326), ST_SRID(rast)))
FROM public.elevation
where rid = ?
How can I figure out what rid to use?
Thanks,
Greg