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.

4 Answers 4

10

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
6

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

Another interesting approach would be to use the View Attribute Form button, here you can define what fields to show or hide. To open it click on the form icon from the Identify Features results panel. View Feature Form

To edit what fields to show follow these steps:

  1. open the Layer properties and head to Attributes From
  2. Change the mode on the top to Drag and Drop Designers
  3. Click on the + and add a new tab or a group box container
  4. Drag all the fields you do not want to see instantaneously to the tab, or you can decide to place the fields in a group box and collapse it. You can decide to hide the tab, based on the condition of your data.

Or you can just keep it simple and just drag the unwanted fields to the tab/group and click ok - voila, once you open the View Feature Form you will only see the important stuff on top. Not like in HTML hover you can also copy the data in this solution. Adding a new tab and dragging the fields to it

Might I add that the View Attribute Form is a tool that did not receive the credit it deserves! The Feature is quite powerful in addition to it being very customizable, with the ability to color fields, adding graphs or html blocks, it works amazingly with relational tables, for example I can use a a value from one of the fields to show or hide a tab from a different table. This really comes handy by reducing number of clicks and finding related features from different layers.

2

Here is a PyQGIS solution.

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

# imports
from qgis.core import QgsProject, QgsEditorWidgetSetup

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

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

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

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:

# imports
from qgis.core import QgsProject

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 you have read our privacy policy.

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