This may be trivial question, but I'm confused, what is the difference between geometry and $geometry in QGIS? I didn't find any examples of using this function.
Particularly I'm interested in geometry, in what cases it is helpful?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
Right next to the list of functions your screenshot is of, should be the currently selected function's documentation. For me, with 2.18.12 those read:
$geometry Returns the geometry of the current feature. Can be used for processing with other functions.
geometry Returns a feature's geometry.
This is like the different of a method versus a function in object-oriented programming. $geometry is this/self's geometry. You can think of it more like an attribute or property maybe.
geometry on the other hand requires/allows you to pass a feature to it and it will return the corresponding geometry. As the documentation shows, you can use this to get the geometry from a attribute-based feature selection:
geometry( get_feature(layer, attributeField, value) )
What else you can do with it is just limited by your creativity and the sources for features to pass to it. :)
$geometry returns the geometry of the current feature as in
geometry returns the geometry of a specific feature as in
geom_to_wkt(geometry(get_feature('my_layer', 'my_feature', feature_id)))
You would use the second case if you wanted, for example, to process the current feature against a specific feature: