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.35k stars 2.98k forks source link

Raster layer properties - show bit depth #47400

Open simonwright-jbarisk opened 2 years ago

simonwright-jbarisk commented 2 years ago

What is the bug or the crash?

On the Layer Properties dialogue for a raster dataset, the data type isn't being correctly reported.

For example, for an unsigned integer raster dataset created with NBITS=4, QGIS is reporting that the data type is Byte - Eight bit unsigned integer.

When the same raster is queried using GDAL the correct datatype with NBITS=4 is reported.

Steps to reproduce the issue

  1. Right-click a raster layer and select Properties...
  2. On the Layer Properties dialogue, select the Information section
  3. Data type is incorrectly reported from some raster dataset layers.

Versions

QGIS version 3.18.3-Zürich QGIS code revision 735cc85be9 Compiled against Qt 5.11.2 Running against Qt 5.11.2 Compiled against GDAL/OGR 3.1.4 Running against GDAL/OGR 3.1.4 Compiled against GEOS 3.8.1-CAPI-1.13.3 Running against GEOS 3.8.1-CAPI-1.13.3 Compiled against SQLite 3.29.0 Running against SQLite 3.29.0 PostgreSQL Client Version 11.5 SpatiaLite Version 4.3.0 QWT Version 6.1.3 QScintilla2 Version 2.10.8 Compiled against PROJ 6.3.2 Running against PROJ Rel. 6.3.2, May 1st, 2020 OS Version Windows 10 (10.0) Active python plugins farm_qc_hydrology; JBAGeometryValidator_02; JBAHydrologyUpdater_15; kart; latlontools; loadthemall; pluginbuilder3; plugin_reloader; processing_wbt; profiletool; QGIS3-getWKT; QuickWKT; db_manager; MetaSearch; processing

Supported QGIS version

New profile

Additional context

No response

gioman commented 2 years ago

For example, for an unsigned integer raster dataset created with NBITS=4, QGIS is reporting that the data type is Byte - Eight bit unsigned integer.

@simonwright-jbarisk please attach a sample.

simonwright-jbarisk commented 2 years ago

Example GTiff in the attached zip file. nbits_equals_four.zip

alexbruy commented 2 years ago

@simonwright-jbarisk I am afraid there is no bug here. Your raster indeed has a Byte data type, this can be easily checked with gdalinfo

Driver: GTiff/GeoTIFF
Files: nbits_equals_four.tif
Size is 430, 283
Coordinate System is:
GEOGCRS["WGS 84",
    DATUM["World Geodetic System 1984",
        ELLIPSOID["WGS 84",6378137,298.257223563,
            LENGTHUNIT["metre",1]]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["geodetic latitude (Lat)",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433]],
        AXIS["geodetic longitude (Lon)",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433]],
    ID["EPSG",4326]]
Data axis to CRS axis mapping: 2,1
Origin = (-6.911091838066483,50.247071235089699)
Pixel Size = (0.000060058068491,-0.000060058068491)
Metadata:
  AREA_OR_POINT=Area
  CATEGORY=RB
  COUNTRY=GB
  HISTORY={"tasks": [{"task": "publish", "uuid": "c4ad8a73-1741-4508-85e9-00d0c367ba92", "start_time": "2016-08-02T11:25:45.769409", "source": "/home/farm/farmpy/test/data/prepared2/raw_swu.tif", "host": "rml-vbnk01", "version": "jbafarm v0.11.0", "run_time": "0:00:00.168134", "task_params": {"max_replace": 7.0, "cell_count": 5, "max_limit": 7.0, "src_path": "/home/farm/farmpy/test/data/prepared2/raw_swu.tif", "min_limit": 0.05}, "end_time": "2016-08-02T11:25:45.937543", "user": "farm"}, {"run_time": "0:00:00.090984", "task": "banded_depths", "uuid": "a3bde863-b629-4174-b784-e1aa0eb594c2", "start_time": "2016-08-08T16:31:18.055000", "source": "/home/farm/farmpy/test/data/prepared2/GB_FLSW_U_RP_5m_27700.tif", "host": "rml-vbnk01", "version": "jbafarm v0.11.3", "user": "farm", "task_params": {"src_path": "/home/farm/farmpy/test/data/prepared2/GB_FLSW_U_RP_5m_27700.tif", "reclass_args": [[0.01, 0.05, 1.0], [0.05, 0.1, 2.0], [0.1, 0.3, 3.0], [0.3, 1.0, 4.0], [1.0, 10.0, 5.0]]}, "end_time": "2016-08-08T16:31:18.145984"}, {"task": "export", "uuid": "990bdd51-3c3d-4cb1-88dd-aadfb0e69ce7", "start_time": "2016-08-09T09:21:08.098098", "source": "/home/farm/farmpy/test/data/prepared2/GB_201608_FLSW_U_RB_5m_27700.tif", "host": "rml-vbnk01", "version": "jbafarm v0.11.3", "user": "farm", "task_params": {"output_country": null, "projection": 4326, "layer": null, "split_bands": false, "out_format": "GTiff", "esri_vat": true, "gridfile": null, "vrt": false, "tilesize_m": null, "esri_proj": true, "compress": false, "tilesize": null, "bands": null, "src_path": "/home/farm/farmpy/test/data/prepared2/GB_201608_FLSW_U_RB_5m_27700.tif", "output_directory": "/home/farm/farmpy/test/data/output/GeoTiff", "bbox": null, "return_period": [75], "fieldname": null, "cutline": null, "gridlayer": null, "tilesize_token": null}, "end_time": "2016-08-09T09:21:08.166601", "run_time": "0:00:00.068503"}, {"uuid": "0c366d36-07c6-40be-83b4-b04e72cfe6f6", "user": "simonwright@jbanorthwest.co.uk", "host": "rml-dev03.jbanorthwest.co.uk", "version": "farmlib v1.10.9", "start_time": "2020-12-02T11:28:12.549656", "end_time": "2020-12-02T11:28:12.549852", "run_time": "0:00:00.000196", "task": "export", "source": "/home/jbanorthwest.co.uk/simonwright/repos/farmmap/farm_test/data/flood_maps/GB_201608_FLSW_U_RP75_RB_5m_4326.tif", "task_params": {"use_q_for_rp": false, "short_name_format": false, "build_pyramids": false, "tap": false, "date_string": null, "no_data_value": 15.0, "nbits": "4", "resampling_alg": null, "cell_size": null, "suffix": null, "compress": false, "output_category": null, "output_country": null, "split_bands": false, "vrt": false, "fieldname": null, "gridlayer": null, "gridfile": null, "tilesize_token": null, "tilesize_m": null, "tilesize": null, "esri_proj": false, "esri_vat": false, "layer": null, "cutline": null, "proj4": null, "projection": 4326, "bbox": null, "bands": null, "return_period": null, "out_format": "GTiff", "output_directory": ".", "src_path": "/home/jbanorthwest.co.uk/simonwright/repos/farmmap/farm_test/data/flood_maps/GB_201608_FLSW_U_RP75_RB_5m_4326.tif"}}]}
  MODELLED_RESOLUTION=5m
  PERIL=FLSW_U
  UNITS=m
Image Structure Metadata:
  COMPRESSION=LZW
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (  -6.9110918,  50.2470712) (  6d54'39.93"W, 50d14'49.46"N)
Lower Left  (  -6.9110918,  50.2300748) (  6d54'39.93"W, 50d13'48.27"N)
Upper Right (  -6.8852669,  50.2470712) (  6d53' 6.96"W, 50d14'49.46"N)
Lower Right (  -6.8852669,  50.2300748) (  6d53' 6.96"W, 50d13'48.27"N)
Center      (  -6.8981794,  50.2385730) (  6d53'53.45"W, 50d14'18.86"N)
Band 1 Block=256x256 Type=Byte, ColorInterp=Red
  NoData Value=15
  Metadata:
    RETURN_PERIOD=75
    UNITS=m
  Image Structure Metadata:
    NBITS=4

As you can see, the only band of this file reports Type=Byte.

simonwright-jbarisk commented 2 years ago

Hi Alexander

Many thanks for your reply.

But on the QGIS Layer properties dialogue the same dataset is reported as having a a "Byte - Eight bit unsigned integer" data type - see the highlighted area in the attached image: image

It would be really useful and would it be more correct to show the data type as being 4 bit unsigned integer?

Many thanks, best wishes, Simon.

alexbruy commented 2 years ago

I am afraid you did not get the point of my comment. QGIS shows the same data type as GDAL does, so no bug here.

simonwright-jbarisk commented 2 years ago

OK. But do you not think that it would also be really useful to show the bit depth of the raster dataset layer as well?

gioman commented 2 years ago

Changed to feature request.

simonwright-jbarisk commented 2 years ago

Awesome, many thanks!