VERIFIED SOLUTION i

How to create lines from pairs of x/y coordinates in MapInfo Pro

Product affected: MapInfo Pro™, MapBasic™
The following process can be used to convert a table of coordinates to a table of lines.

The table must contain the coordinates for the beginning and the end of the line.
For example, set up columns so the x/y (longitude/latitude) vales are in pairs that represent the beginning and the end node for each line similar to the following:

User-added image
It is very important to make any changes on a copy of the table; it may be necessary to use the original data at a later time.

Before proceeding with the update, make sure that the table in which the lines will be stored is mappable.
To make the table mappable, make sure the table's "Table Is Mappable" box is checked. (Table tab>Table>Modify Structure: Table Is Mappable)

To execute the command to convert the points to lines or create lines for the table, open the MapBasic Window through (Home tab>Tool windows>MapBasic), type in the following command, substituting the actual table name for "point_table_name".

Select and highlight the whole line and press enter:

update point_table_name set obj=createline(Start_X, Start_Y,End_X,End_Y)
User-added image
User-added image

Start_X, Start_Y, End_X and End_Y represent the columns in point_table that have the starting and ending coordinates for each line.

Important Notes:
If a layout window was opened in this session of MapInfo, re-start MapInfo and then execute the command before opening another layout window.

If the table being used is projected, the line objects may not be created properly. To work around this situation, open up a new map window of a table in a different projection than the one the table being used in this operation is in. Choose Map>Options and click on the projection button. Choose the projection of the table the create lines operation is being used on. Click OK. Then, execute the MapBasic command and the lines should be created correctly.



 
UPDATED:  September 7, 2017