Max Rady College of Medicine

Concept: Distance to Hospital - A Method to Calculate

 Printer friendly

Concept Description

Last Updated: 1998-10-14


    Randy Walld has developed a SAS program that calculates distance to the hospital of the record (as the bird flies), distance to the nearest hospital and distance to the nearest teaching hospital.

    The program looks at the distances to all hospital facilities in the HOSPLIST file. If the distance to only one hospital is needed, then the program can be made much simpler.

    The variables that must be found in the user's dataset are Postal Code, Hospital Number and Municipal Code. The following is an explanation of the general principles used to calculate distance to hospital.

Postal Code Conversion File

    The program calculates the patient to hospital distance using the Statistics Canada 1991 Postal Code Conversion File (PCCF). The PCCF provides correspondence between six-digit postal codes and Statistics Canada's standard geographical areas (e.g. Census divisions, Census subdivisions). The PCCF links over 726,000 postal code records (created up to Dec 91) to the geographical areas used in the 1991 Census and to Universal Transverse Mercator (UTM) coordinates and latitude/longitude coordinates. This file provides the link between the postal code of a patient or hospital and geographic location.


    There are two main problems with using the PCCF for determining geographic location based on postal code:

    • Some rural postal codes are very large. In rural areas, a postal code can range over a considerable area. Assigning one set of coordinates to an area entails a certain degree of error. In the absence of any more detailed information, however, this error is unavoidable.

    • Postal code location sometimes refers to post office. There are several types of postal codes which give as their location the coordinates of the post office where the delivery originates. About 9.6% of the records on the 1991 PCCF have codes of these types. These are codes which refer to post office boxes, rural route delivery, General delivery, and a few other rarely used (less than .1%) types.


    For the 90.4% of records on the PCCF which do not refer to the location of the post office, the coordinates given can be used as the location of the patient's residence. As stated above, this is less accurate in rural areas than in urban areas.

    The error associated with the 9.6% of codes which refer to post office location depends on how far the patient lives from his or her post office. For this reason, these codes are generally not very useful in determining patient location.

    Fortunately, there is a way to find the approximate location of patients who have postal codes that refer to a post office. In addition to postal code, the patient's municipal code is also recorded on the hospital file. This code refers to the actual location of the patient, unlike postal code which refers to their mailing address. On the 1991 population file (derived from Manitoba Health data), there were 281 municipal codes, with an average population of 4058.

    Using this population file, the coordinates for all postal codes coinciding with each municipal code were tabulated. Codes which refer to post office location were excluded, and the remaining sets of coordinates were averaged for each municipal code. This produced one "average" location which was used as the patient location when their postal code referred to a post office.

    This strategy was not applied to records for Treaty Indians with post office postal codes, since their municipal code refers to the reserve they are associated with regardless of whether they live there or not. In these cases, the post office location was used. This is not a big problem since only about 0.5% of hospital records have both a Treaty Indian municipal code and a postal code which refers to a post office location.


  • Urban Hospitals: In urban areas, postal codes are sufficiently dense that hospital location can be coded very accurately.
  • Rural Hospitals: Because of the large size of most rural postal codes, rural hospitals are not so easy to locate. In these cases the location of the rural post office was always selected because the hospital was more likely to be located in town (along with the post office) rather than in the outlying areas served by the post office.


    Once a reasonably accurate set of coordinates has been derived for both patient and hospital, the distance can be calculated. What is actually calculated is the shortest (or "great circle") distance along the surface of a perfect sphere with the same diameter as the earth. This is only a rough approximation of the real distance one would travel using winding roads that follow local geography.

    The following formula was used for the distance calculations:
    D= 6,370,997*arcos(sin(LAT1)*sin(LAT2) + cos(LAT1)*cos(LAT2)*cos(LONG1-LONG2))

    WHERE :
    D = distance in meters
    LAT1 = latitude of point1 (in radians)
    LONG1 = longitude of point1 (in radians)
    LAT2 = latitude of point2 (in radians)
    LONG2 = longitude of point2 (in radians)
    arcos = arc cosine
    cos = cosine
    sin = sine
    and 6,370,997 is the radius of the sphere in meters.
    Latitude and longitude can be converted from degrees to radians by dividing by 57.29577951.

Related terms 


  • Ng E, Wilkins R, Perras A. How far is it to the nearest hospital? Calculating distances using the Statistics Canada Postal Code Conversion File. Health Rep 1993;5(2):179-188. [Abstract] (View)
  • Statistics Canada Geography Division. Postal Code Conversion File Codebook (1st edition). Ottawa, ON: Statistics Canada; 1993.(View)


  • postal codes
  • rural hospital
  • teaching hospitals

Contact us

Manitoba Centre for Health Policy
Community Health Sciences, Max Rady College of Medicine,
Rady Faculty of Health Sciences,
Room 408-727 McDermot Ave.
University of Manitoba
Winnipeg, MB R3E 3P5 Canada