[GIS] Create closest-distance line in MapInfo

mapbasicmapinfo

As part of a larger program (basically a remake and extension of DistanceCalc) I want to programmatically create a line between the two closest points of two regions in MapInfo.

The ObjectDistance function effectively measures this line and returns its length but there is no way to store the line itself.

The "Nearest" statement almost does what I want but it does too much! – it measures from one site (or each item in a table) to each item in another table. Also it puts the results in a table whereas I want to manipulate them before storing them.

Is there a simple way to do this?

Best Answer

Have a look at this MapBasic function:

ConnectObjects( ) function

Purpose

Returns an object representing the shortest or longest distance between two objects. You can call this function from the MapBasic Window in MapInfo Professional.