With the following queries I've exported a raster (GTiff) from my postgis database:
1.Creating a large object:
WITH buffer AS ( SELECT id, ST_Buffer(geom,50) AS geom FROM polygon_table), clip AS ( SELECT partnumber, ST_Union(ST_Clip(a.rast, 1,b.geom, TRUE)) AS rast FROM aspect a JOIN buffer b ON ST_Intersects(a.rast, b.geom) GROUP BY partnumber) SELECT oid, lowrite(lo_open(oid, 131072), png) As num_bytes FROM ( VALUES (lo_create(0), ST_AsGDALRaster(((SELECT ST_Union(rast) FROM clip)),'GTiff') )) As v(oid,png)
2.Exporting it to a GTiff file (e.g. with oid=176148)
SELECT lo_export(176148, '/tmp/demo_rast.tif')
(3. Deleting the large object:
The aspect raster data in the postgis database has the following information:
rid | scalex | scaley | srid -----+--------+--------+------- 1 | 25 | -25 | 31468
The aspect raster resolution is 25m. Tiling is 100x100.
When load the raster into QGIS it is slightly displaced. The colored aspect raster is the original. The grayish one is the exported one.
The amount of the displacement is about 2.65m to the west in x direction and about 1.35m to the north in y direction.
Where does this displacement come from?
The problem appears exclusively in QGIS.
When I load both rasters into GRASS GIS there is no displacement. I didn't used the option
Override projection (use location's projection) when I import the rasters into GRASS GIS.
As you can see here:
So is there a general problem (bug) which appears here in QGIS???