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

The $length function returns the Cartesian value when called from the aggregate function #55657

Open
2 tasks done
pigreco opened this issue Dec 19, 2023 · 0 comments
Open
2 tasks done
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Expressions Related to the QGIS expression engine or specific expression functions Field Calculator

Comments

@pigreco
Copy link
Sponsor Contributor

pigreco commented Dec 19, 2023

What is the bug or the crash?

problem description:
I have a linear layer (testOne) and a table (tableOne) without geometry,
I start the field calc from the table and write the following expression to update the len attribute:

aggregate(
layer:='testOne',
aggregate:='array_agg',
expression:=$length) [0]

the result (126671.709 m) is different from what I would expect (126721.310 m), as it returns the Cartesian value of $length and not the ellipsoid one, in fact if I used $length in the testOne vector I would get the desired value.

data:
https://mega.nz/file/pFQnkYxJ#3zNJR0rzH-a4opip3rgkbJoLrRUlNu7-vwXeiUra_Hs

email:
https://lists.osgeo.org/pipermail/qgis-it-user/2023-December/010471.html

Steps to reproduce the issue

  1. create a linear vector with projected SR and add a single line;
  2. create a simple table with a single row;
  3. When updating the table, use the expression below:
aggregate(
layer:='testOne',
aggregate:='array_agg',
expression:=$length) [0]

Versions

OSGeo4W 64b

Tested on QGIS 3.28.13 LTR Florence and on QGIS 3.34.1 Prizren by OSGeo4W - win 10 PRO 64b

Versione di QGIS
3.28.13-Firenze
Revisione codice QGIS
3b4db4f
Versione Qt
5.15.3
Versione Python
3.9.5
Versione GDAL/OGR
3.8.1
Versione PROJ
9.3.1
Versione database del Registro EPSG
v10.098 (2023-11-24)
Versione GEOS
3.12.1-CAPI-1.18.1
Versione SQLite
3.41.1
Versione PDAL
2.6.0
Versione client PostgreSQL
unknown
Versione SpatiaLite
5.1.0
Versione QWT
6.1.6
Versione QScintilla2
2.13.4
Versione SO
Windows 10 Version 2009

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

the project is set up correctly with ellipsoid, i.e. we know that: 'The length calculated by this function respects both the current project's ellipsoid setting and the distance unit settings'

I attach data and example project.
https://mega.nz/file/pFQnkYxJ#3zNJR0rzH-a4opip3rgkbJoLrRUlNu7-vwXeiUra_Hs

@pigreco pigreco added Bug Either a bug report, or a bug fix. Let's hope for the latter! Expressions Related to the QGIS expression engine or specific expression functions Field Calculator labels Dec 19, 2023
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! Expressions Related to the QGIS expression engine or specific expression functions Field Calculator
Projects
None yet
Development

No branches or pull requests

1 participant