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

Impossible to calculate the area of a polygon using the formula $area #57362

Closed
2 tasks done
alexCCI opened this issue May 7, 2024 · 10 comments
Closed
2 tasks done

Impossible to calculate the area of a polygon using the formula $area #57362

alexCCI opened this issue May 7, 2024 · 10 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!

Comments

@alexCCI
Copy link

alexCCI commented May 7, 2024

What is the bug or the crash?

It's impossible to calculate the area of a polygon using the formula $area, it returns a 'NaN' value. However, it remains functional when using geometric functions like area($geometry). The same applies to the perimeter.

Steps to reproduce the issue

  1. Select a polygon layer.
  2. Go to the fields calculator.
  3. Try using the $area formula.

Versions

Tested in QGIS 3.36.2 and 3.34.6

Supported QGIS version

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

New profile

Additional context

No response

@alexCCI alexCCI added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label May 7, 2024
@pigreco
Copy link
Contributor

pigreco commented May 8, 2024

OSGeo4W win 11 pro

I did a test with QGIS 3.34.6 AND 3.36.2, it works!

2024-05-08_08h27_10.mp4

@uclaros
Copy link
Contributor

uclaros commented May 8, 2024

I did a test with QGIS 3.34.6 AND 3.36.2, it works!

Preview works as in your screencast, but the actual calculation of the field values returns nulls.

@uclaros uclaros added the Regression Something which used to work, but doesn't anymore label May 8, 2024
@pigreco
Copy link
Contributor

pigreco commented May 8, 2024

it works for me

2024-05-08_11h09_14.mp4

@uclaros uclaros removed the Regression Something which used to work, but doesn't anymore label May 8, 2024
@uclaros
Copy link
Contributor

uclaros commented May 8, 2024

it works for me

Now I'm confused, it works for me too!
I could have sworn I replicated the issue!

@nyalldawson
Copy link
Collaborator

My gut feeling -- the crs is set incorrectly for the dataset, or it's using a crs which isn't valid for the actual area containing features.

@alexCCI
Copy link
Author

alexCCI commented May 8, 2024

The problem initially occurred in versions installed through OSGeo4W. A complete reinstallation of all components didn't help. I also tried installing the latest version from the standalone .msi file, but the problem persisted. I conducted tests with different layers, in different coordinate systems, and with various projects. Importantly, the area is calculated correctly using area($geometry).

@uclaros
Copy link
Contributor

uclaros commented May 8, 2024

My gut feeling -- the crs is set incorrectly for the dataset, or it's using a crs which isn't valid for the actual area containing features.

This crossed my mind, but the preview displayed a value before clicking ok...

@nyalldawson
Copy link
Collaborator

Ok, let's close until a reproducible workflow is available

@uclaros
Copy link
Contributor

uclaros commented May 8, 2024

@alexCCI can you share a project/data where you can replicate this?

@alexCCI
Copy link
Author

alexCCI commented May 9, 2024

In the end, you were right. The layer I was trying to work with had a personalized coordinate system without an EPSG code. I apologize for the inconvenience.

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!
Projects
None yet
Development

No branches or pull requests

4 participants