9

I have a GDB layer which I've imported into my QGIS 3.16 project.

I am using the "Identify Features" tool to inspect paths, and I'm trying to use the "Identify Results" panel to quickly make note of certain data attribute values.

Unfortunately this database has 130 data attribute rows, which makes it very difficult to find the values I need quickly.

Is there a way to hide or sort the data attribute rows that show up in the Identify Results panel?

QGIS Identify Results Panel

I did try opening the attribute table and was able to hide columns there. My attribute table looks great and it's only showing the data I need. However the "Show Selected Features" filter doesn't seem to work. And while the "Show Features Visible On Map" filter does update results, it won't work for this application. Either way, I would prefer to customize the display of the Identify Results panel. I'm just mentioning that I was successful hiding data in the attributes table, but it did not seem to change the appearance of the Identify Results panel.

3 Answers 3

7

A workaround can be to create a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer... with the columns you want to show, and identify this layer instead:

For example:

select kommunnamn, lanskod, geometry
from ok_ak_riks

enter image description here

6
  • 3
    Very nice, would the virtual layer update after every addition/edit to the main layer?
    – Dror Bogin
    Oct 20, 2021 at 6:52
  • 2
    Yes it will update automatically
    – BERA
    Oct 20, 2021 at 7:00
  • 2
    A very elegant solution.
    – Dror Bogin
    Oct 20, 2021 at 7:00
  • 2
    The updating of the map seems a little bit inconsistent. Sometimes I have to pan the map for the virtual layer to update. But you can set the layer to automaticallly update every n seconds under layer properties.
    – BERA
    Oct 20, 2021 at 7:21
  • I like this solution for a few reasons, but I wasn't able to get the geometry pulled into the virtual layer. No idea what I'm doing wrong there, but this does look like the easiest way to build a data subset for quick reference.
    – ian.pvd
    Oct 20, 2021 at 22:14
5

Unless I'm mistaken you can't do that.
You can however customize map tips in the layer properties menu.
This way you could decide which fields to show, and how since you can use HTML code.
For example with a simple expression:

[% to_string("name") +'\n' + 'Population: '+to_string("pop_est")%]

enter image description here enter image description here

Or adding HTML to style the result:

<h3 style="color:red;">[% to_string("name")%]</h3>
<b>Population: </b>[%to_string("pop_est")%]

enter image description here enter image description here

You just have to make sure you turn map tips on, and simply hover over the feature you want to identify.

enter image description here

EDIT

I've actually written a couple of blog posts about map tips lately which can answer this. Dropping the links for anyone looking to expand about this.

simple HTML map tip - Styling Map Tips In QGIS
Creating an image carousel inside a map tip - Advanced QGIS: Image Slideshows in a Map Tip

1
  • 1
    I had no idea these tool tips could be customized, but this quick workaround helped.
    – ian.pvd
    Oct 20, 2021 at 22:15
2

Here is a solution using PyQGIS.

Let's assume there is a polygon layer called 'test' with the following attribute table, see image below.

input

This is the current result after using the "Identify Features" tool (Ctrl+Shift+I).

identify_1

Proceed with Plugins > Python Console > Show Editor and paste the script below

layer = QgsProject.instance().mapLayersByName("test")[0]
type = 'Hidden'
config = {'Layer':layer.id()}
not_required_fields = ["pop06", "pop618", "pop1835", "pop3565", "pop6599"]

indexs = [layer.fields().indexOf(field) for field in not_required_fields]

for index in indexs:
    field = layer.fields()[index]
    widget_setup = QgsEditorWidgetSetup(type, config)
    layer.setEditorWidgetSetup(index, widget_setup)

enter image description here

Press Run script run script and get the final output (again after using the "Identify Features" tool):

output_1

To exclude these fields from the attribute table use this piece of code:

layer = QgsProject.instance().mapLayersByName("test")[0]
not_required_fields = ["pop06", "pop618", "pop1835", "pop3565", "pop6599"]

config = layer.attributeTableConfig()

columns = config.columns()

for column in columns:
    if column.name in not_required_fields:
        column.hidden = not False

config.setColumns(columns)
layer.setAttributeTableConfig(config)

So, the attribute table now will look like

output_2


References:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.