Bug report #18773
Geometry generator inside Point Cluster style uses project CRS instead of layer CRS
Status: | Open | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | Symbology | ||
Affected QGIS version: | 3.0.1 | Regression?: | No |
Operating System: | Windows 10 & Ubuntu Linux 17.10 | Easy fix?: | No |
Pull Request or Patch supplied: | No | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 26660 |
Description
This problem occurs when the project CRS is different from the point layer CRS.
- If a geometry generator with only $geometry is used in a Single symbol style for a point layer, the points are generated in the CRS of the point layer.
- If a geometry generator with only $geometry (on the original points or on the Cluster points) is used in a Point cluster style for a point layer, the points or Cluster points are generated in the CRS of the project.
- Create a project with CRS EPSG:4326
- Load a point layer with CRS EPSG:31370
- Change the Symbol layer type from Simple Marker to Geometry Generator
- Set the Geometry Type to Point/Multipoint
- Set the expression to $geometry
Result:
The points are created on the same place as if a Simple marker style was used (this is the expected result). If the expression is changed to geom_to_wkt($geometry) in the Expression Dialog box, the Output Preview shows coordinates in EPSG:31370, so the points are generated in the CRS of the original points layer.
PART 1
- Create a project with CRS EPSG:4326
- Load a point layer with CRS EPSG:31370
- Change the layer type from Single Symbol to Point Cluster
- Click on Renderer settings...
- Change the Symbol layer type from Simple Marker to Geometry Generator
- Set the Geometry Type to Point/Multipoint
- Set the expression to $geometry
Result:
The Cluster points are created near the place of the points where a Simple marker style would place the points, but the points created by the Geometry generator are not visible near the cluster points. If the expression is changed to geom_to_wkt($geometry) in the Expression Dialog box, the Output Preview shows coordinates in EPSG:4326, so the points are generated in the CRS of project.
- Change the expression to transform($geometry,'EPSG:4326','EPSG:31370')
Result:
The Cluster points and original points are created near the place of the points like when a Simple marker style was used. Inside the Point Cluster style this counterintuitive expression is needed to get the points at the correct place.
A similar problem occurs when the Geometry Generator is applied on the Cluster Markers instead of on the original points.
Steps to reproduce with Point Cluster style (geometry generator on cluster points):PART 1
- Create a project with CRS EPSG:4326
- Load a point layer with CRS EPSG:31370
- Change the layer type from Single Symbol to Point Cluster
- Click on the cluster symbol button
- Change the Symbol layer type of the Cluster points from Simple Marker to Geometry Generator
- Set the Geometry Type to Point/Multipoint
- Set the expression to $geometry
Result:
The original points are created on the same place as if a Simple marker style was used. The Cluster points are created near the place where the 0,0 coordinates in EPSG:31370 are (north of Paris), because the coordinates in EPSG:4326 are much smaller than the coordinates in EPSG:31370.
- Change the expression to transform($geometry,'EPSG:4326','EPSG:31370')
Result:
The Cluster points and original points are created near the place of the points like when a Simple marker style was used. Inside the Point Cluster style this counterintuitive expression is needed to get the Cluster points at the correct place.
History
#1 Updated by Tom Chadwin over 6 years ago
Confirmed. This results in geometry expression functions operating differently on a clustered layer to an unclustered layer (as far as I can tell).
#2 Updated by Tom Chadwin over 6 years ago
- File clustered_geometry_generator_CRS_bug.zip added
#3 Updated by Tom Chadwin over 6 years ago
In the project I attached, the red features are non-clustered geometry generators, and have the correct appearance - the geometry generator draws a square around the point in the layer's CRS (EPSG:27700). When rendered in the project's CRS (EPSG:4326), it has the correct projected "perspective".
The blue and yellow squares are point-clustered - blue is feature, yellow is cluster. If the same geometry generator expression is used, the features are in the wrong location. They can be moved to the correct location (as I've done in the attached project), by wrapping the generator expression as follows:
transform(<generator_expression>, <project_crs>, <layer_crs>)
That moves the features into the correct location. However, it means that the square drawn by the generator appears *un*projected - it's still a rotated square, and has not been transformed to the correct projected perspective. In addition, in the generator expression to draw the square, I have to change from layer CRS units to project CRS units. I find this hard to understand, since I am combining the latlng unit distances with $x and $y, and the latter are in metres.
I hope this explanation makes some sense - my lack of confidence with projection means I struggle to identify if this is a bug, but I certainly cannot achieve what I want to, and what I can achieve without a cluster.