qgis / QGIS-Documentation

QGIS Documentation
https://docs.qgis.org/latest
471 stars 695 forks source link

Raster Attribute Table GUI (Request in QGIS) #7877

Open qgis-bot opened 1 year ago

qgis-bot commented 1 year ago

Request for documentation

From pull request QGIS/qgis#50687 Author: @elpaso QGIS version: 3.30

Raster Attribute Table GUI

PR Description:

Raster Attribute Table GUI

Here are a few examples about different use cases and workflows:

Automatic creation of style from a RAT when adding a raster to the project

Automatic loading works for both embedded RATs and sidecar VAT.DBF with same basename of the raster.

rat-float-1

RAT reclassification

Reclassification of a raster based on a different column

rat-reclassify-vegetation

RAT Identify

Values from the RAT row corresponding to the pixel value are shown in identify

rat-identify

RAT Properties

RAT is also available in the raster properties.

rat-properties-editing

RAT editing

RATs offer basic editing capabilities

rat-editing

RAT creation from current classification

RATs can be created from paletted or singleband pseudocolor styles:

rat-creation

Commits tagged with [need-docs] or [FEATURE]

DelazJ commented 1 year ago

@elpaso @GlenRice-NOAA Can you provide some information/documentation/data on this RAT thing. I looked at the changelog but the information looked minimalist to me. I'd be happy to document this but I'm far from having your background with rasters. I've always thought raster only stored pixel values, so you can imagine...

  1. Well I have this landcover dataset that displays values in the "attribute table" tab, but not the srtm one. Why?
  2. Then I can add a field (nbr_pix) to the table, but I'm unable to use it for classification. Why? image Btw: would it make sense to have a way to multi edit a field in this dialog? File a feature request?
  3. What do all these settings in the "Add column" dialog refer to?
  4. What is, if any, the relation between the RAT classification/values and the symbology tab

Well, I think feeding the above points would greatly help. Or if you feel like providing a text for the docs (even as txt), I'd be happier to do the formatting stuffs and integrate.

Thanks in advance.

elpaso commented 1 year ago

@DelazJ I can try to explain the main concepts:

The RAT is basically a way to store the raster classification by associating raster values (single values or ranges) with an optional description (label) and can also optionally store a color used to represent the value(s). Additional columns can be used to reclassify the raster, as shown in the sample videos attached where different classes (one for each raster value) are reclassified in fewer classes (for instance all types of trees are merged into a single class).

Some raster formats can store the RAT internally, GDAL can also store the RAT in the .aux.xml file and some softwares (including now QGIS) can import/export the RAT from/to a DBF file.

The RAT data model is based on the GDAL implementation, to be honest I have extensively looked for specifications or documentation about the RAT when developing the RAT plugins firsts and the C++ implementation more recently and I was surprised by the total lack of it (or my inability to find it), my understanding of the RAT data model originates mainly from samples taken from GDAL and from NOAA who financed the work.

Now, coming to the column types, GDAL defines a few column roles and data types that are stored in the .aux.xml and are used to understand the role of the column, for example a column can have a specific role (see : https://gdal.org/doxygen/gdal_8h.html#a27bf786b965d5227da1acc2a4cab69a1 ) which is useful to know what is the purpose of the column and what you can do with that column (e.g. if it is a part of a color definition or the column containing the values for the classification or the labels etc.).

The relation with the symbology tab does exist because the paletted or singleband pseudocolor styles can be created from a RAT (actually they are automatically when the raster is loaded and it comes with a RAT) and a RAT can be created and exported from paletted or singleband pseudocolor styles, this should also answer to your question n. 1.

I hope this helps to clarify but feel free to ping me if you have further questions.

kmithof commented 9 months ago

Hi, Thank you for adding RAT to the QGIS core. I just tried with GeoTiffs to create a RAT. It works, but I cannot create a vat.tbf. Even if I chose this option an .aux.xml file created. Further I cannot edit the table. It is enabled. What could be the Problem? I use QGIS 3.34.2 on Win10. Thank you

elpaso commented 9 months ago

Hi, Thank you for adding RAT to the QGIS core. I just tried with GeoTiffs to create a RAT. It works, but I cannot create a vat.tbf. Even if I chose this option an .aux.xml file created. Further I cannot edit the table. It is enabled. What could be the Problem? I use QGIS 3.34.2 on Win10. Thank you

https://github.com/qgis/QGIS/issues/55711