I am trying to compute certain statistics from an elevation (DEM) raster column but at certain points the raster tiles are not aligned, and continue to not be aligned even though ST_SnapToGrid() or ST_Resample() are called.
with buffer (buf) as (values (ST_Transform(ST_Buffer( ST_SetSRID(ST_Point(-66.0005555554938, 18.0005555553954), 4269)::geography, 30)::geometry, 4269))), raster as (select ST_Union(ST_SnapToGrid(rast, -66.0005555554938, 18.0005555553954)) as rast from raster_table, buffer where ST_Intersects(rast, buf)) select rast From raster;
with a similar approach using ST_Resample and another CTE to use the first raster returned from the intersection as a sort of reference. I have tried different resample methods and different values for
maxerr, include 0, 1.0, and 100, but none of these prevent the error
SQL Error [XX000]: ERROR: rt_raster_from_two_rasters: The two rasters provided do not have the same alignment from being raised. Is there something I'm missing or a better way to do this?