Bug report #12406
QgsDistanceArea.measure(geometry) - for Polygons in WGS84
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
Associated revisions
Fix #12406 (measured area is wrong when computed on ellipsoid)
Introduced in e568493
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
Fixed in changeset 19c1dc69e9ff09cbb4323cb73a64c7cd805dc63f.
#8 Updated by Martin Dobias over 9 years ago
Backported to 2.8 in 1949fe9c86215e7818c9b21e14c80d4e417c2d7a
#9 Updated by Giovanni Manghi over 9 years ago
- Resolution set to fixed/implemented