I have setup a custom processing/python script to determine the shortest path on a network based on the code for Dijkstra's algorithm here,
Similar to the Road Graph plugin, I want to obtain the distance of the path as well. I've setup my code as below but I keep getting errors for the convertMeasurement function.
QgsDistanceArea.convertMeasurement(float, QGis.UnitType, QGis.UnitType, bool) -> (float, QGis.UnitType): not enough arguments See log for more details
Not sure what I'm doing wrong. I've been researching and googling this problem but can't seem to find a solution. I've included some commented out lines of code as well to show what other options I've tried.
distance_measure = QgsDistanceArea() distance_measure.setSourceCrs(crs) distance_measure.setEllipsoidalMode(True) #distance_measure.setEllipsoid('GDA94') dist_unit = QGis.UnitType() dist_unit_deg = QGis.UnitType(2) #dist_unit print dist_unit print dist_unit_deg #print type(dist_unit) #QgsDistanceArea.convertLengthMeasurement(distance_measure, dist_unit) dist_val = distance_measure.measureLength(rb.asGeometry()) print dist_val QgsDistanceArea.convertMeasurement(distance_measure, dist_unit_deg, dist_unit, False) print distance_measure.lengthUnits() #print QgsDistanceArea.formatDistance(dist_val,QGis.Meters,5)