Can someone help me understand what I am doing wrong in my calculation of the distance between two points?
My code is as follows:
import qgis crs = qgis.core.QgsCoordinateReferenceSystem() crs.createFromSrsId(3452) # EPSG:4326 disCur = qgis.core.QgsDistanceArea() disCur.setSourceCrs(crs) disCur.setEllipsoid('WGS84') disCur.setEllipsoidalMode(True) point1 = qgis.core.QgsPoint(35.895392, -78.758094) point2 = qgis.core.QgsPoint(35.898154, -78.680271) disTot = disCur.measureLine(point1, point2) print disTot, disCur.lengthUnits()
It is my expectation to get an answer of 4.36 mi or 7.02 km (from GoogleMaps) but my code gives me a distance of 0.077871997361 and a value of 3 for the lengthUnits.
- What should I change in my code to the length in either meters, km or miles?
- What are the units of the distance as given my code above?
- Why do I get an integer value of 3 for the lengthUnits()?