Bug report #18204

Failure to load PostGIS raster without bands

Added by Paolo Cavallini over 2 years ago. Updated about 2 years ago.

Status:Closed
Priority:High
Assignee:Alessandro Pasotti
Category:DB Manager
Affected QGIS version:3.3(master) Regression?:Yes
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:worksforme
Crashes QGIS or corrupts data:No Copied to github as #:26095

Description

List of tables, inlcuding rasters, are correctly displayed in DB Manager. When double clicking, loading fails with the message:

Cannot open GDAL dataset PG: dbname=
Couldn't establish database connection

In the dialog, username and password are requested.
Vectors are loaded correctly.

To replicate:

-- create an empty table
CREATE TABLE public.test_raster
(
  rid integer,
  rast raster,
  CONSTRAINT enforce_height_rast CHECK (st_height(rast) = ANY
(ARRAY[100, 24])),
  CONSTRAINT enforce_width_rast CHECK (st_width(rast) = ANY (ARRAY[100,
24])),
  CONSTRAINT enforce_srid_rast CHECK (st_srid(rast) = 4326)
);

-- create an empty raster
INSERT INTO test_raster(rid,rast)
VALUES(1, ST_MakeEmptyRaster( 100, 100, 0.0005, 0.0005, 1, 1, 0, 0, 4326) );

-- add primary key
ALTER TABLE test_raster ADD CONSTRAINT test_pkey PRIMARY KEY (rid);

History

#1 Updated by Giovanni Manghi over 2 years ago

  • Priority changed from Normal to High

#2 Updated by Giovanni Manghi about 2 years ago

  • Affected QGIS version changed from 3.0.0 to 3.3(master)

#3 Updated by Alessandro Pasotti about 2 years ago

  • Assignee set to Alessandro Pasotti

#4 Updated by Alessandro Pasotti about 2 years ago

  • Status changed from Open to Feedback

I could not reproduce exactly the same issue as I get a different message from DB manager: "Cannot get GDAL raster band:"

As reported by https://postgis.net/docs/RT_ST_MakeEmptyRaster.html , a raster with 0 bands is created by ST_MakeEmptyRaster, QGIS needs at least one band so this error makes sense.

The error you mention about the connection appears to be different and I cannot reproduce it.

#5 Updated by Alessandro Pasotti about 2 years ago

  • Subject changed from Failure to load PostGIS raster to Failure to load PostGIS raster without bands

#6 Updated by Giovanni Manghi about 2 years ago

The error you mention about the connection appears to be different and I cannot reproduce it.

something seems to have changed(?). Now I see the same as you, but a few days ago I have confirmed what described by the reporter.

#7 Updated by Alessandro Pasotti about 2 years ago

In any event, the raster generated with ST_MakeEmptyRaster has no bands and will never be opened by QGIS.

Can we close this?

#8 Updated by Paolo Cavallini about 2 years ago

  • Resolution set to worksforme
  • Status changed from Feedback to Closed

Thanks

Also available in: Atom PDF