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?
2 Answers
If you open DatabaseManager, you can navigate to 'virtual layers'. Select your layer and look in the tab 'info'.
Here you get a list of all your fields, the geometry-field included.
-
1Thanks, 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 ?– EliasseFeb 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– PieterBFeb 1, 2021 at 18:34
-
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.
$geometry
?