1

I have 3 layers in QGIS (shapefiles) :

two point layers : Houses and fire hydrants

and one line layer : Road

I want to calculate the shortest distance between each fire hydrant and a house using the road. So, I want to calculate the distance from each house (point) to the nearest fire hydrant using the road.

This picture illustrates what I aim : enter image description here

4
2

You can perform your analysis with QGIS by QNEAT3 plugin using OD-Matrix Algorithms, here you find algoritms description QNEAT3 - OD-Matrices .

The function OD-Matrix calculates travel distance and/or time from each origin points to each destination points.

To perform this analysis, after have installated QNEAT3 plugin, you have to choose, in processing tools,the function 'OD MATRIX from layer as line'.

QNEAT3 plugin using OD-Matrix Algorithms

Then set:

  • Network layer: that is your roads layer.
  • From-Point Layer: your houses layer.
  • Unique Point ID Field: an attribute that identifies univocly houses points.
  • To-Point Layer: your fire hydrants points layer
  • Unique Point ID Field: an attribute that identifies univocly fire hydrants.
  • Optimization criterion: you can choose to consider distance or time as value to calculate.

As advanced options, you can set:

  • default speed or, if you have, assign a field that has velocity value.
  • Topology tollerance: that is expressed in project SR measure units and it is useful if your points aren't joined to the road.

After algorithm execution, you have a matrix with distance value from each houses to each fire hydrants.

enter image description here

Now you have to select best origin-destination pair value. To do that, you have to perform SQL query.

In processing tools choose run SQL function

QGIS SQL function

and set as input layer 'Output OD Matrix' and write this query

select origin_id, destination_id, min(total_cost) as minimum_travel_cost, geometry
from input1
group by origin_id

Result of this query is a new matrix where there are the minimum travel cost value from houses to fire hydrants.

So you can identify which fire hydrant every house is related to.

enter image description here

Tutorial on this kind of analysis is this: https://www.qgistutorials.com/en/docs/3/origin_destination_matrix.html

1
  • Thank you kind sir !!!
    – AlphaB
    Jul 28 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.