3

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???

  • What is the spatial references of the original raster? Sometimes small displacements like you have can be explained by the shift between different datums. – Regan Sarwas Apr 25 '14 at 15:50
  • The projection is DHDN_3_Degree_Gauss_Zone_4, EPSG: 31468. I executed gdalinfo -mm and both raster files have the same information, but the second authority of the exported raster. Original (colored) raster: UNIT["metre",1, AUTHORITY["EPSG","9001"]], AUTHORITY["EPSG","31468"]]. Means, the AUTHORITY["EPSG","31468"]] is missing in the exported raster. – Stefan Apr 25 '14 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.