[GIS] Difference between geometry and $geometry QGIS
geometryqgis
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?
Best Answer
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:
$geometryReturns the geometry of the current feature. Can be used for processing with other functions.
geometryReturns 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:
As far as I know JTS does nothing with the SRID value (see this email). You will need to use GeoTools to reproject your features to a common projection and then call intersection on them. The result will then be in the common projection and you can then project back to one or both of the input projections.
Once you've calculated the difference between your polygons (let's call this delta), take the difference between the exterior of delta and the exterior of your brown polygon2: result = delta.exterior.difference(polygon2.exterior). Note that the sense of the difference will be significant and it may be tricky to generalize this to all possible polygons. Good luck!
Best Answer
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:
What else you can do with it is just limited by your creativity and the sources for features to pass to it. :)