How to calculate line length on Mapinfo Professional using SQL Query

Mapinfo has a built in SQL Query which can be used for many purposes. On this tutorial, I am going to show you how to calculate line length on Mapinfo Professional using SQL Query feature. Its pretty easy to calculate line or polyline using SQL Query.

First, open the table which contains lines or polylines we want to calculate.


On the picture above, I have a table called Line which contains 3 objects (2 lines and one polyline). Each object has a unique name in Field1. Here is the browser table.


Ok, now we want to calculate the length of each line using SQL Query.

Go to Query | SQL Select. The SQL Select window will opened and we need to enter the required fields and other details.


  1. Select Columns

On the first point, we need to enter Select Column. On the example, I enter the following:

Field1, SphericalObjectLen(obj, “m”)

The SphericalObjectLen(obj, “m”) can be selected from the function drop down menu on the right side of the SQL Select window. The function will calculate the length of the object in meter. You can also change “m” into “km” or other units.

2. From Table

On the From Table column, select the table that we want to calculate (which contains line/polyline). On this example, my table called Line.

3. Group by column

This entry will separate the length of the object based on column we choose. On this example, the Field1 is used.

4. into table named

On this section, the query will be saved into a new temporary table. I use Calculate_length for the name. We can also save this result as new Mapinfo Table if we want.

Press OK to display the result. Don’t forget to check the Browse Result option.



Leave a Reply

Your email address will not be published. Required fields are marked *