Bug report #21854

Add Grass raster layer with pyqgis 3 crash qgis

Added by Sylvain POULAIN 9 months ago. Updated 9 months ago.

Status:Closed
Priority:High
Assignee:-
Category:PyQGIS Console
Affected QGIS version:3.6.0 Regression?:No
Operating System:Archlinux Easy fix?:No
Pull Request or Patch supplied:No Resolution:invalid
Crashes QGIS or corrupts data:Yes Copied to github as #:29669

Description

Step to reproduce :

- Open an empty project,
- Open python console,
- Add Raster layer with :
iface.addRasterLayer("/path/to/grassdb/sector/mapset/cellhd/raster_file", "raster_name")
- Waiting ... crash
- Message from qgis launch via terminal :
Warning 1: GRASS fatal error: Input window changed while maps are open for read. Map name <raster_name>
  • stack smashing detected ***: <unknown> terminated
    Aborted (core dumped)

Opening through qgis browser by double clic open it fine.

History

#1 Updated by Giovanni Manghi 9 months ago

  • Crashes QGIS or corrupts data changed from No to Yes
  • Status changed from Open to Feedback
  • Priority changed from Normal to High

It's completely out of my league... just a hunch here... are you trying to add a "grass raster layer" as if it was a normal file based raster dataset? If yes I don't think that it would work anyway.

#2 Updated by Sylvain POULAIN 9 months ago

Giovanni Manghi wrote:

are you trying to add a "grass raster layer" as if it was a normal file based raster dataset? If yes I don't think that it would work anyway.

Yes this is it ! Ok I have to found a workaround.

But thinking it could be working because gdal read it :

$ gdalinfo --formats | grep GRASS
GRASS raster (ro): GRASS Rasters (5.7+)
GRASSASCIIGrid raster (rov): GRASS ASCII Grid

$ gdalinfo $HOME/SIG/GEOBASE/GRASSDB/MAURICE/data/cellhd/wh_789
Warning 1: GRASS warning: GISBASE environment variable was not set, using:
/opt/grass7
Driver: GRASS/GRASS Rasters (5.7+)
Files: /home/sylvain/SIG/GEOBASE/GRASSDB/MAURICE/data/cellhd/wh_789
Size is 1852, 1403
Coordinate System is:
PROJCS["UTM Zone 40, Southern Hemisphere",
GEOGCS["wgs84",
DATUM["WGS_1984",
SPHEROID["WGS_1984",6378137,298.257223563]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",57],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",10000000],
UNIT["Meter",1]]
Origin = (539214.000000000000000,7771490.000000000000000)
Pixel Size = (9.998920086393088,-9.999287241625089)
Corner Coordinates:
Upper Left ( 539214.000, 7771490.000) ( 57d22'30.86"E, 20d 9'12.53"S)
Lower Left ( 539214.000, 7757461.000) ( 57d22'31.96"E, 20d16'48.91"S)
Upper Right ( 557732.000, 7771490.000) ( 57d33' 8.76"E, 20d 9'10.85"S)
Lower Right ( 557732.000, 7757461.000) ( 57d33'10.37"E, 20d16'47.21"S)
Center ( 548473.000, 7764475.500) ( 57d27'50.49"E, 20d12'59.96"S)
Band 1 Block=1852x1 Type=Float64, ColorInterp=Palette
Min=0.000 Max=66.319
NoData Value=nan
Metadata:
COLOR_TABLE_RULES_COUNT=1
COLOR_TABLE_RULE_RGB_0=6.631894e-01 6.631894e+01 0 240 255 0 50 170
Color Table (RGB with 68 entries)
0: 0,0,0,0
1: 0,240,255,255
2: 0,237,254,255
3: 0,234,252,255
...

And qgis browser panel launch it fine so my question now is : how qgis browser panel, in qgis desktop, launch the raster ? Through gdal ? Through grass plugin ?

#3 Updated by Sylvain POULAIN 9 months ago

Ok found here line 417 : https://trac.osgeo.org/qgis/browser/trunk/qgis/src/plugins/grass/qgsgrassplugin.cpp
Better way to load it without crash =>

- Add Raster layer with :
iface.addRasterLayer("/path/to/grassdb/sector/mapset/cellhd/raster_file", "raster_name", "grassdata")

You can close the ticket !

#4 Updated by Giovanni Manghi 9 months ago

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

Also available in: Atom PDF