qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.59k stars 3k forks source link

QGIS visualizes only one tiles from a PostGIS raster table #39427

Closed miladmoradi89 closed 2 years ago

miladmoradi89 commented 4 years ago

Description

When I open DB manager tool in QGIS 3.10.10, then I click on the PostGIS raster table and I click add to convas, I can see all the raster tiles visualized together. but with 3.14, I can only see one tile!! the rest of them are not displayed. I tried it with 2 different tables and the result is the same.

The exact problem QGIS 3.14 only shows 1 tiles of PostGIS raster and ignores the rest of them

just one more detail, I remembere that my table did not have a primary key. Maybe it matters!!

elpaso commented 4 years ago

Can you attach an (possibly small) SQL dump of the raster table that shows the error?

miladmoradi89 commented 4 years ago

I tried with different tables the result is the same the old version of QGIS shows all the tiles but the last one just shows a random tile not the whole raster. my boss did not allow me to share my table as it was sensitive you know better than me how to create a random table but I created this one and again I just had 1 tile with new QGIS:

select ST_AsRaster(geom, 100, 100, '8BUI', floor(random() * 10 + 1)::int) rast into table_for_qgis_guys from base_grid

base grid is a simple grid representing the tiles of raster.

I just tried to add this raster table by right clicking on the name of this table in browser window. and then, I clicked add layer to project

but only one tile is visualized!!

elpaso commented 4 years ago

Works for me on current master, can you try a nightly build?

image

CREATE OR REPLACE FUNCTION ST_CreateFishnet(
        nrow integer, ncol integer,
        xsize float8, ysize float8,
        x0 float8 DEFAULT 0, y0 float8 DEFAULT 0,
        OUT "row" integer, OUT col integer,
        OUT geom geometry)
    RETURNS SETOF record AS
$$
SELECT i + 1 AS row, j + 1 AS col, ST_Translate(cell, j * $3 + $5, i * $4 + $6) AS geom
FROM generate_series(0, $1 - 1) AS i,
     generate_series(0, $2 - 1) AS j,
(
SELECT ('POLYGON((0 0, 0 '||$4||', '||$3||' '||$4||', '||$3||' 0,0 0))')::geometry AS cell
) AS foo;
$$ LANGUAGE sql IMMUTABLE STRICT;

SELECT * into base_grid FROM ST_CreateFishnet(4, 6, 10, 10) ;

select ST_AsRaster(geom, 100, 100, '8BUI', floor(random() * 10 + 1)::int) rast
into table_for_qgis_guys
from base_grid;
miladmoradi89 commented 4 years ago

It is surprising!! what you see is in fact what I see in my previous QGIS. but in the new QGIS I see only one row of table!

I tried your code

this is what I see

image

elpaso commented 4 years ago

Can you try at least 3.14 ?

One important thing to notice:

<= 3.10 uses GDAL provider 3.14 and subsequent use a native pg raster provider

in any event I tried both: GDAL and native providers and they show the same result on master.

miladmoradi89 commented 4 years ago

I am not professional but what I installed and is not working well is QGIS Standalone Installer Version 3.14 (64 bit)

and I said I checked it on 3.10.10 and it was working well.

elpaso commented 4 years ago

Ah, sorry it's been a long day and I missed that.

gioman commented 4 years ago

I am not professional but what I installed and is not working well is QGIS Standalone Installer Version 3.14 (64 bit)

@miladmoradi89 can you attach the raster and add the exact commands used to import it?

miladmoradi89 commented 4 years ago

I did not import it. I used some calculation with ST_Union() and some other functions to produce the raster table. But I checked it with other raster tables and non of them was visualized well in QGIS. I tried this code and the QGIS just visualized 1 tile of it:

` CREATE OR REPLACE FUNCTION ST_CreateFishnet( nrow integer, ncol integer, xsize float8, ysize float8, x0 float8 DEFAULT 0, y0 float8 DEFAULT 0, OUT "row" integer, OUT col integer, OUT geom geometry) RETURNS SETOF record AS $$ SELECT i + 1 AS row, j + 1 AS col, ST_Translate(cell, j $3 + $5, i $4 + $6) AS geom FROM generate_series(0, $1 - 1) AS i, generate_series(0, $2 - 1) AS j, ( SELECT ('POLYGON((0 0, 0 '||$4||', '||$3||' '||$4||', '||$3||' 0,0 0))')::geometry AS cell ) AS foo; $$ LANGUAGE sql IMMUTABLE STRICT;

SELECT * into base_grid FROM ST_CreateFishnet(4, 6, 10, 10) ;

select ST_AsRaster(geom, 100, 100, '8BUI', floor(random() * 10 + 1)::int) rast into table_for_qgis_guys from base_grid; `

You can see the image that I have attached from QGIS. That image is the result of this code. If you want you can give me another code and I will visualized it in my QGIS Version 3.14 (64 bit).

gioman commented 4 years ago

I did not import it.

@miladmoradi89 I'll re-formulate the request: Can you please attach all the necessary data needed to replicate the issue, along with all the necessary (detailed) steps? thanks!

miladmoradi89 commented 4 years ago

I did not import it.

@miladmoradi89 I'll re-formulate the request: Can you please attach all the necessary data needed to replicate the issue, along with all the necessary (detailed) steps? thanks!

STEPS:

1- Open pgAdmin and run this code in any database:

`CREATE OR REPLACE FUNCTION ST_CreateFishnet( nrow integer, ncol integer, xsize float8, ysize float8, x0 float8 DEFAULT 0, y0 float8 DEFAULT 0, OUT "row" integer, OUT col integer, OUT geom geometry) RETURNS SETOF record AS $$ SELECT i + 1 AS row, j + 1 AS col, ST_Translate(cell, j $3 + $5, i $4 + $6) AS geom FROM generate_series(0, $1 - 1) AS i, generate_series(0, $2 - 1) AS j, ( SELECT ('POLYGON((0 0, 0 '||$4||', '||$3||' '||$4||', '||$3||' 0,0 0))')::geometry AS cell ) AS foo; $$ LANGUAGE sql IMMUTABLE STRICT;

SELECT * into base_grid FROM ST_CreateFishnet(4, 6, 10, 10) ;

select ST_AsRaster(geom, 100, 100, '8BUI', floor(random() * 10 + 1)::int) rast into table_for_qgis_guys from base_grid;`

2- Install and Open QGIS (QGIS Standalone Installer Version 3.14 (64 bit))

3- Connect to the database where you run the previous code in GIS browser.

4- either right click on your raster table "table_for_qgis_guys". Then, select add to convas.

5- or open database manager tool in QGIS and then right click on the table "table_for_qgis_guys" and click add to convas

you will see that only one of the many tiles is visualized and the rest of tiles are not visualized in QGIS. If you want to see the difference open the table raster table in QGIS with od versions of QGIS. I did it with 3.10.10 and it was able to visualize all the tiles.

You do not need any other material to test it.

I am using windows 10 with the postgresql 12.4 the 64b version.

gioman commented 4 years ago

I can see the difference between QGIS 3.10 and above, thanks.

andywicht commented 3 years ago

I can also confirm this behavior. QGIS (3.14.16 in my case on Win10) only loads the tile with rid = 1.

image

gioman commented 3 years ago

I can also confirm this behavior. QGIS (3.14.16 in my case on Win10) only loads the tile with rid = 1.

@andywicht that is outdated and unsupported, you must try with 3.16.1

Pedro-Murteira commented 2 years ago

@miladmoradi89 Hello, is this still valid on recent releases?

miladmoradi89 commented 2 years ago

Hello,

Which version do you want me to check for you?

Milad

On Fri, Apr 29, 2022 at 10:24 AM pmurteira @.***> wrote:

@miladmoradi89 https://github.com/miladmoradi89 Hello, is this still valid on recent releases?

— Reply to this email directly, view it on GitHub https://github.com/qgis/QGIS/issues/39427#issuecomment-1113384026, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH6UNYB6A5BSE3NPHVYWJYTVHPWLNANCNFSM4STM2DKQ . You are receiving this because you were mentioned.Message ID: @.***>

Pedro-Murteira commented 2 years ago

@miladmoradi89 the current versions are 3.22.6 (LTR) and 3.24.2 (LR).

miladmoradi89 commented 2 years ago

Yes, I checked the version 3.24.2 and it was good at visualizing rasters. Previously, I used to see just one tile, but now, I can see all tiles of the raster stored in PostGIS tables.

On Fri, Dec 4, 2020 at 5:18 AM Andreas Wicht @.***> wrote:

I can also confirm this behavior. QGIS (3.14.16 in my case on Win10) only loads the tile with rid = 1.

[image: image] https://user-images.githubusercontent.com/21099522/101151654-43402f80-3622-11eb-9707-81c523bf477c.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/qgis/QGIS/issues/39427#issuecomment-738699834, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH6UNYCSF6ZQ5IGTXKBW6CDSTCZODANCNFSM4STM2DKQ .