Finding the closest fire hydrant

Finding the closest fire hydrant-image


  • PostgreSQL, PostGIS, pgRouting


  • QGIS

Network analysis with pgRouting

I developed a series of SQL queries (Postgres, PostGIS and pgRouting) to find the closest fire hydrant in the city of Toronto, given a pair of coordinates.

Being the fire hydrants and the input coordinates not necessarily in the network, I relied on the "pgr_withPoints" function, from the pgRouting extension, which can route points even if they aren't nodes of the network.