So here is the issue, i am trying to extract values from a big raster divided in 200 or so tiles and applying them to a selection. The points are startpoints, endpoints and midpoints from vector items, lines created using flow tools on SAGA. Everytime i try to run the query it returns me the following error:
NOTICE: Attempting to get pixel value with out of range raster coordinates: CONTEXT: fonction PL/pgsql st_value(raster,integer,geometry,boolean)
Here is my function so far, tried to use a "where" query in order to force him to read only the raster data where it intersects with my lines but that didn't fix a thing and the query failed.
SELECT
tronc.id AS id,
tronc.geom AS geom,
ST_value(raster.rast, ST_startpoint(tronc.geom), TRUE) AS alt_startpoint,
ST_value(raster.rast, ST_endpoint(tronc.geom), TRUE) AS alt_endpoint,
ST_value(raster.rast, ST_line_interpolate_point(tronc.geom, 0.5), TRUE) AS mid_point,
(ST_value(raster.rast, ST_startpoint(tronc.geom), TRUE) + ST_value(raster.rast, ST_endpoint(tronc.geom), TRUE) + ST_value(raster.rast, ST_line_interpolate_point(tronc.geom, 0.5), TRUE))/3 AS mean
FROM
sinuosity.channels as tronc,
rasters.tr_rge_alti_5m_2016 AS raster
WHERE
ST_intesects(tronc.geom, raster.rast, 1)