Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Grass raster layer with pyqgis 3 crash qgis #29669

Closed
qgib opened this issue Apr 15, 2019 · 4 comments
Closed

Add Grass raster layer with pyqgis 3 crash qgis #29669

qgib opened this issue Apr 15, 2019 · 4 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption High Priority PyQGIS Related to the PyQGIS API

Comments

@qgib
Copy link
Contributor

qgib commented Apr 15, 2019

Author Name: Sylvain POULAIN (@kikislater)
Original Redmine Issue: 21854
Affected QGIS version: 3.6.0
Redmine category:pyqgis_console


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 ***: terminated
    Aborted (core dumped)

Opening through qgis browser by double clic open it fine.

@qgib
Copy link
Contributor Author

qgib commented Apr 15, 2019

Author Name: Giovanni Manghi (@gioman)


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.


  • crashes_corrupts_data was changed from 0 to 1
  • status_id was changed from Open to Feedback
  • priority_id was changed from Normal to High

@qgib
Copy link
Contributor Author

qgib commented Apr 16, 2019

Author Name: Sylvain POULAIN (@kikislater)


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 ?

@qgib
Copy link
Contributor Author

qgib commented Apr 16, 2019

Author Name: Sylvain POULAIN (@kikislater)


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 !

@qgib
Copy link
Contributor Author

qgib commented Apr 16, 2019

Author Name: Giovanni Manghi (@gioman)


  • resolution was changed from to invalid
  • status_id was changed from Feedback to Closed

@qgib qgib closed this as completed Apr 16, 2019
@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! High Priority PyQGIS Related to the PyQGIS API Crash/Data Corruption labels May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Crash/Data Corruption High Priority PyQGIS Related to the PyQGIS API
Projects
None yet
Development

No branches or pull requests

1 participant