Function that returns distance information between geometries

ST_Distance takes two geometries and, optionally, a unit as input parameters, and returns the shortest distance between any point in the first geometry to any point in the second geometry, measured in the specified units.

If the second geometry is not represented in the same spatial reference system as the first geometry, it will be converted to the other spatial reference system.

If either of the two specified geometries is null or is empty, then null is returned.

For example, ST_Distance could report the shortest distance an aircraft must travel between two locations. Figure 1 illustrates this information.

Figure 1. Minimum distance between two cities. ST_Distance can take the coordinates for the locations of Los Angeles and Chicago as input, and return a value denoting the minimum distance between these locations.

The figure shows a map of the United States with a straight line between points labeled Los Angeles and Chicago.

top Points on a map measuring distance