2

I am running Postgresql 9.5.5 with Postgis 2.2.1 on Ubuntu. I have imported ASTER GDEM elevation information as a raster and query it for elevation using geo coordinates. Currently I use

ST_NearestValue(elevation.rast, ST_SetSRID($POINT,4326), false)

With (e.g.)

$POINT = ST_SetSRID(ST_MakePoint(8.4255, 49.0113), 4326)

but as ASTER GDEM is "only" sampled at 30m x 30m I need to get a (weighted) average of the nearest 4 or 16 available samples. Which is the most elegant (and performant) way to do this?

I tried

SELECT (ST_Intersection(elevation.rast, ST_Expand($POINT),0.0001))).val
FROM elevation
WHERE ST_Intersects(elevation.rast, ST_Expand($POINT),0.0001));

but this only returns the height without the exact position, so the samples can not be weighted by distance. It also seems rather ugly and the expansion factor needs to be calculated depending on the latitude.

I am rather new to postgis and may have missed even a simple solution.

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.