Group schools based on driving distance into 8 regions

Every two years, we reclassify all of the schools in the state based on enrollment. We then divide each classification into 8 regions, based on proximity to each other in drive time.

Each classification has 40 schools. What is the best way to determine which schools are closest to each other to group them into regions? I have geocoded each school’s physical address. What is next?

The usual way to do this is to use a routing package which provides a time/distance matrix between the points. Most of those which use OSM and provide this capability offer this as a paid for option, although they may offer a free tier. This is the API call for OSRM. I think Graphhopper is similar.

As you are specifically looking for distances for a one-off calculation it might be possible to do this either by querying the distance between each pair of school via one of the online apis (slowly, pause for several seconds between queries), or alternatively using pgrouting within PostGIS, but this requires preparing routing data.

I know less about the last step of clustering into clusters of equal size, although I have done it in the past with a tool which required I took data out of PostGIS.