-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OD Matrix miscalculates time cost if network CRS does not use linear units of meters #36
Comments
Correction/Addition: it seems like all linear units for distance or time calculations are calculated as meters for the network cost because the defaults in the QGIS network builder are to calculate distance with the WGS84 ellipsoid and the QNEAT3 plugin is using that default setting. Entry and Exit costs are treated differently: there is currently an option to use planar or ellipsoidal calculations, and neither method ensures that linear units are calculated in meters if the input network layer CRS and/or project CRS use different linear units. This leads to inconsistent distance calculations between the network cost and entry/exit costs and incorrect calculations for CRSs using units other than meters. It would be straightforward to force all entry/exit costs to use the same qgsDistanceArea calculator technique as the network graph to calculate distance in meters with WGS84 ellipsoidal calculations. I suggest removing the ellipsoidal/planar option from the algorithms because the network cost is already defaulting in all cases to WGS84 ellipsoidal distance in meters. Working on a pull request for this now... |
I can confirm I am having this issue as well. I have a network that I run routemapping on the attached file of routes (geometry and id only provided here). DetailsSearch at points:
Items
Distance appears correct (5820 m), used this site to confirm distances in meters. Base parameters (not accounting for speed changes, testing 111 km/1 degree): { 'DEFAULT_DIRECTION' : 2, 'DEFAULT_SPEED' : 555, 'DIRECTION_FIELD' : '',
'END_POINT' : '-84.378275,34.033410\n',
'ENTRY_COST_CALCULATION_METHOD' : 0,
'INPUT' : 'bug_lines.geojson',
'OUTPUT' : 'TEMPORARY_OUTPUT', 'SPEED_FIELD' : '', 'START_POINT' : '-84.399238,34.009124\n', 'STRATEGY' : 1,
'TOLERANCE' : 0, 'VALUE_BACKWARD' : '', 'VALUE_BOTH' : '', 'VALUE_FORWARD' : '' } Distance: 5820.1376886 m
I tested the last (should be equal to 1) with powers of 10 applied to the speed to confirm the issue is linear. The value appears to be off by 30.9213 x power of 10, consistently. Note: this only confirmed how far off this is between these points. I did not test alternate points (yet). Image of path |
I checked a few other points and can confirm that the factor is approximately 30.92 off. |
It's true. You can find a resolution in this pull request: #37 |
Implemented in 1.0.5 |
QNEAT3 does not correctly apply a unit conversion if the network layer uses a CRS with linear units other than meters for time-optimization. For example, one speed cost was calculated as 36 seconds in a network layer using meters, but once projected to a coordinate system using feet, the cost was calculated at 118 seconds -- incorrect by the same factor as the conversion from feet to meters.
It seems like the QGIS network builder is automatically converting linear units into meters using
self.meter_to_unit_factor
, so calling the speed strategy function with a speed conversion factor ofunit_to_meter_factor * 1000.0 / 3600.0
is negating the unit conversion that has already been applied to distance. I'm making an educated guess here, since I can't find the code in the QGIS algorithms where the linear unit conversion happens, but clearly it happening for distance strategy and I assume that it must also be doing the same for speed strategy. In either cases, revisingunit_to_meter_factor * 1000.0 / 3600.0
to1000.0 / 3600.0
is fixing the bug.The text was updated successfully, but these errors were encountered: