Skip to main content
added 252 characters in body
Source Link
Bera
  • 77.7k
  • 14
  • 78
  • 187

For using that class and get acceptable results in meters you need two lines of additional code (with 'setEllipsoid' and 'setEllipsoidalMode' methods); as it can be observed at follows:

point1 = QgsPoint(-46.443077,-67.51561)
point2 = QgsPoint(-46.4446,-67.512778)

#Create a measure object
distance = QgsDistanceArea()
distance.setEllipsoid('WGS84')
distance.setEllipsoidalMode(True) #*

#Measure the distance
m = distance.measureLine(point1, point2)

print m

After running it at Python Console of QGIS result is 322.474631789 meters.

(* From Backwards Incompatible Changes: setEllipsoidalMode() was removed. Ellipsoidal calculations are now enabled whenever a valid ellipsoid() has been set. Set the ellipsoid to 'NONE' to disable ellipsoidal calculations.)

For using that class and get acceptable results in meters you need two lines of additional code (with 'setEllipsoid' and 'setEllipsoidalMode' methods); as it can be observed at follows:

point1 = QgsPoint(-46.443077,-67.51561)
point2 = QgsPoint(-46.4446,-67.512778)

#Create a measure object
distance = QgsDistanceArea()
distance.setEllipsoid('WGS84')
distance.setEllipsoidalMode(True)

#Measure the distance
m = distance.measureLine(point1, point2)

print m

After running it at Python Console of QGIS result is 322.474631789 meters.

For using that class and get acceptable results in meters you need two lines of additional code (with 'setEllipsoid' and 'setEllipsoidalMode' methods); as it can be observed at follows:

point1 = QgsPoint(-46.443077,-67.51561)
point2 = QgsPoint(-46.4446,-67.512778)

#Create a measure object
distance = QgsDistanceArea()
distance.setEllipsoid('WGS84')
distance.setEllipsoidalMode(True) #*

#Measure the distance
m = distance.measureLine(point1, point2)

print m

After running it at Python Console of QGIS result is 322.474631789 meters.

(* From Backwards Incompatible Changes: setEllipsoidalMode() was removed. Ellipsoidal calculations are now enabled whenever a valid ellipsoid() has been set. Set the ellipsoid to 'NONE' to disable ellipsoidal calculations.)

Source Link
xunilk
  • 30.2k
  • 4
  • 43
  • 82

For using that class and get acceptable results in meters you need two lines of additional code (with 'setEllipsoid' and 'setEllipsoidalMode' methods); as it can be observed at follows:

point1 = QgsPoint(-46.443077,-67.51561)
point2 = QgsPoint(-46.4446,-67.512778)

#Create a measure object
distance = QgsDistanceArea()
distance.setEllipsoid('WGS84')
distance.setEllipsoidalMode(True)

#Measure the distance
m = distance.measureLine(point1, point2)

print m

After running it at Python Console of QGIS result is 322.474631789 meters.