Bug report #12406

QgsDistanceArea.measure(geometry) - for Polygons in WGS84

Added by Jens Deutschmann almost 10 years ago. Updated over 9 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:-
Affected QGIS version:2.8.0 Regression?:No
Operating System:Windows Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:20579

Description

This is since Version 2.8 (newer i dont know). The Method measures something but the Nummber is extremly tiny. And there for wrong!
If you project it to a CooRdinateSystem somewhere in the world it would measure something nearly correctly (because of the incorrect projection). But this could not be a workaround... if you need the whole world.


Related issues

Related to QGIS Application - Bug report #12057: Computed area is wrong when reprojection is active Closed 2015-01-26

Associated revisions

Revision 19c1dc69
Added by Martin Dobias over 9 years ago

Fix #12406 (measured area is wrong when computed on ellipsoid)

Introduced in e568493

Revision 1949fe9c
Added by Martin Dobias over 9 years ago

Fix #12406 (measured area is wrong when computed on ellipsoid)

Introduced in e568493

History

#1 Updated by Jens Deutschmann almost 10 years ago

I forgot to highlight that this occurs in my Python-Script (Plugin), dont know if its happaning in the FieldCalculator too. Its only a question of time to figure it out, sry.

#2 Updated by Martin Dobias almost 10 years ago

Could you paste a snipped of code where you use QgsDistanceArea? I assume you didn't enable ellipsoid mode, so the measurements you get are using Euclidean distance on your coordinates. You probably want to do something like this:

d = QgsDistanceArea()
d.setEllipsoidalMode(True)
d.setEllipsoid("WGS84")
d.measure(QgsGeometry.fromPolyline([QgsPoint(0,0),QgsPoint(1,0)]))

#3 Updated by Jens Deutschmann almost 10 years ago

Here is a snipped, but i dont think its that Problem because in QGIS 2.6 it all works well!? And i think i enabled it this way....

def analyzeGeometry(self, geometry, layer, info):
crs = QgsCoordinateReferenceSystem(layer.dataProvider().crs())
calculator = QgsDistanceArea()
calculator.setSourceCrs(crs)
calculator.setEllipsoid(crs.ellipsoidAcronym())
calculator.setEllipsoidalMode(crs.geographicFlag())
....
....
elif geometry.type() == QGis.Polygon:
self.add(info, 'num_polygons', 1)
self.add(info, 'tot_poly_area', int(calculator.measure(geometry)/1000000))
self.add(info, 'tot_poly_perimeter', int(calculator.measurePerimeter(geometry)/1000))

#4 Updated by Martin Dobias almost 10 years ago

The code snippet above unfortunately does not help much without knowing the parameters/outputs.

Please try to provide a sample of CRS configuration + geometry + expected vs actual results.

#5 Updated by Giovanni Manghi over 9 years ago

  • Target version changed from Version 2.8 to Version 2.8.2

#6 Updated by Giovanni Manghi over 9 years ago

  • Status changed from Open to Feedback

#7 Updated by Martin Dobias over 9 years ago

  • Status changed from Feedback to Closed

#9 Updated by Giovanni Manghi over 9 years ago

  • Resolution set to fixed/implemented

Also available in: Atom PDF