Wednesday 15 June 2016

qgis - Raster slightly displaced after exporting from PostGIS database


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: SELECT lo_unlink(176148))



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.


enter image description here


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?



UPDATE


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:


enter image description here


So is there a general problem (bug) which appears here in QGIS???




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...