A couple of days ago I was asked to calculate some distances for people, from where they lived to where they worked…I scratched my head a little and then went to turn on the ArcGIS spatial join tool….but then thought of how this could be done in QGIS. The answer? The Hub Distance tool, part of the MMQGIS set of tools.
I’ll run through how to use this tool below using some arbetuary points and a pretend hospital to “calculate the distance to the hospital”
Let’s consider the image below, there are multiple houses and a hospital. The houses are on one layer and the hospital is on it’s own layer.
Select the “Hub Distance” tool as below:
The houses are the SOURCE layer and the Hospital is the DESTINATION layer, there is also the option to set your options for the unit of distance (Note that you should be using a local projection for metres)
If everything went to plan you should have some lines now connected between the “hub” [hospital] and the houses. The distance will be within a field HUBDist – this can be used for labelling:
And don’t forget to adjust the formatting to limit the number of decimal places shown, unless you want 7 decimal places!