MI_CentroidDistance

Description

Returns the geographic distance between the centroids of two geometry objects.

Syntax

MI_CentroidDistance ( geom1, geom2, unit, calculationType )

Arguments

geom1 is an expression which returns a geometry,

geom2 is an expression which returns a geometry,

unit is a linear unit specification, and

calculationType is a string that indicates whether to perform a Spherical or Cartesian calculation. There is no default.

Example

Returns the distance between the centriods of the specified geomety and the countries.

select MI_CentroidDistance(Obj,MI_Box(-13.36676789,8.05796847,79.06334219,62.70540978,'epsg:4326'),'mi','Cartesian') as theResult from countries where country in ('Mauritania','Mali','Algeria')

Remarks

Calculates the distance between two points. If either of the geometry arguments, geom1 or geom2, is anything other than a point geometry, the centroid of the geometry will be used in the calculation. The value returned is a double and represents a value in the units specified by the units argument.

Valid values for unit are the following distance units:

Value Description
mi miles
km kilometers
in inches
ft feet
yd yards
mm millimeters
cm centimeters
m meters
survey ft US Survey feet
nmi nautical miles
twip twips
pt points
pica picas
degree degrees
li links
ch chains
rd rods