Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geometry generator inside Point Cluster style uses project CRS instead of layer CRS #26660

Closed
qgib opened this issue Apr 19, 2018 · 6 comments
Closed
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Feedback Waiting on the submitter for answers stale Uh oh! Seems this work is abandoned, and the PR is about to close. Symbology Related to vector layer symbology or renderers

Comments

@qgib
Copy link
Contributor

qgib commented Apr 19, 2018

Author Name: Michel Stuyts (@mstuyts)
Original Redmine Issue: 18773
Affected QGIS version: 3.0.1
Redmine category:symbology


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.

Steps to reproduce with Single symbol style:

  1. Create a project with CRS EPSG:4326
  2. Load a point layer with CRS EPSG:31370
  3. Change the Symbol layer type from Simple Marker to Geometry Generator
  4. Set the Geometry Type to Point/Multipoint
  5. 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.

Steps to reproduce with Point Cluster style (geometry generator on original points):
PART 1

  1. Create a project with CRS EPSG:4326
  2. Load a point layer with CRS EPSG:31370
  3. Change the layer type from Single Symbol to Point Cluster
  4. Click on Renderer settings...
  5. Change the Symbol layer type from Simple Marker to Geometry Generator
  6. Set the Geometry Type to Point/Multipoint
  7. 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.

PART 2

  1. 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

  1. Create a project with CRS EPSG:4326
  2. Load a point layer with CRS EPSG:31370
  3. Change the layer type from Single Symbol to Point Cluster
  4. Click on the cluster symbol button
  5. Change the Symbol layer type of the Cluster points from Simple Marker to Geometry Generator
  6. Set the Geometry Type to Point/Multipoint
  7. 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.

PART 2

  1. 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.


@qgib
Copy link
Contributor Author

qgib commented Apr 19, 2018

Author Name: Tom Chadwin (@tomchadwin)


Confirmed. This results in geometry expression functions operating differently on a clustered layer to an unclustered layer (as far as I can tell).

@qgib
Copy link
Contributor Author

qgib commented Apr 19, 2018

Author Name: Tom Chadwin (@tomchadwin)


  • 12646 was configured as clustered_geometry_generator_CRS_bug.zip

@qgib
Copy link
Contributor Author

qgib commented Apr 20, 2018

Author Name: Tom Chadwin (@tomchadwin)


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 unprojected - 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.

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Symbology Related to vector layer symbology or renderers labels May 25, 2019
@gioman gioman added the Feedback Waiting on the submitter for answers label Jan 29, 2022
@gioman
Copy link
Contributor

gioman commented Jan 29, 2022

@mstuyts @tomchadwin the original issue seems fixed to me.

In a project with CRS 4326 and a point layer in a project CRS then in the context of the cluster renderer

geom_to_wkt($geometry)

returns projected coordinates.

However... while this

centroid(buffer($geometry,1000))

works fine in a normal symbology, in the context of the cluster renderer the isolated points are a no show.

Can you confirm?

@github-actions
Copy link

The QGIS project highly values your report and would love to see it addressed. However, this issue has been left in feedback mode for the last 14 days and is being automatically marked as "stale".
If you would like to continue with this issue, please provide any missing information or answer any open questions. If you could resolve the issue yourself meanwhile, please leave a note for future readers with the same problem and close the issue.
In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this issue.
If there is no further activity on this issue, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Feb 13, 2022
@github-actions
Copy link

While we hate to see this happen, this issue has been automatically closed because it has not had any activity in the last 42 days despite being marked as feedback. If this issue should be reconsidered, please follow the guidelines in the previous comment and reopen this issue.
Or, if you have any further questions, there are also further support channels that can help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Feedback Waiting on the submitter for answers stale Uh oh! Seems this work is abandoned, and the PR is about to close. Symbology Related to vector layer symbology or renderers
Projects
None yet
Development

No branches or pull requests

2 participants