4

Depending on the table I'm working on, the geometry column does not always have the same name, for example in my data it is called sometimes "the_geom", "geometry", "geom", or even "geometrie". How can I get the name of this attribute in QGIS?

1
  • What does your geometry column contain what you can't access via $geometry?
    – Erik
    Feb 1, 2021 at 11:00

2 Answers 2

7

If you open DatabaseManager, you can navigate to 'virtual layers'. Select your layer and look in the tab 'info'.

enter image description here

Here you get a list of all your fields, the geometry-field included.

3
  • 1
    Thanks, however there is a problem, I tried with a random table. The field name is different in QGIS DB Manager ("geometry") and in PostgreSQL (" geometrie ", the real name). It looks like whatever the name of the geometry column, it is renamed by default "geometry" in DB Manager. Am I right or wrong ?
    – Eliasse
    Feb 1, 2021 at 13:06
  • 1
    @Eliasse You can access your postgres-table via DBmanager. Select the table and look in the info-tab. There the name of your geometrycolumn will be shown as registered in PostGIS
    – PieterB
    Feb 1, 2021 at 18:34
  • Thanks it's working !
    – Eliasse
    Feb 8, 2021 at 9:04
1

A bit late but I Had the same problem when defining a dynamic query for a virtual layer and stumbled over this discussion.

My solution was the understanding, that in QGis queries/expressions the "geometry"/"$geometry"-pseudo-SQL-keyword allows the access to any vector-geometry-souce without knowing the name of that column, even if there is no physical column, think about shape-file-Layers.

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.