# MI_DistanceToEdge

## Description

Returns the distance between two geometries using the computation type and distance units. Specifically, the distance between two closest points of the two geometries is determined. When a geometry is inside another geometry, the shortest distance between the two geometries is returned with a positive distance value.

## Syntax

MI_DistanceToEdge ( geom1, geom2, unit, calculationType)

## Arguments

`geom1` is an expression which returns a geometry, or a geometry construct

`geom2` is an expression which returns a geometry, or a geometry construct

`unit` is a linear unit specification, and

`calculationType` is a string that indicates whether to
perform a Spherical or Cartesian calculation. The default is calculated based on the
coordinate system of the first geometry.

## Example

Returns the distance to edge from the specified geometry to each country.

```
select MI_DistanceToEdge(MI_Box(-20,-20,20,20,'epsg:4326'),Obj,'mi','Spherical') as distanceToEdge from countries where country in ('Canada','Vietnam','Brazil','China','Japan')
```

## Remarks

Calculates the distance between two geometries. The value returned is a double and represents a value in the units specified by the `units` argument.

Valid values for `unit` are these distance units:

Value | Description |
---|---|

mi | miles |

km | kilometers |

in | inches |

ft | feet |

yd | yards |

cm | centimeters |

m | meters |