VERIFIED SOLUTION i
X

How to determine the lengths of each side of a polygon in MapInfo Professional

UPDATED: April 10, 2017


In MapInfo Professional, users cannot automatically determine the length of each side of a polygon. MapInfo can only determine the total area of a polygon.  

To determine the length of each side of a polygon, MapBasic code will need to be written and compiled to update all sides of a polygon in a table record. 

Users will need to Download and install MapBasic with the corresponding MapInfo Professional and users may have to reference the MapBasic Documentation

Steps:

1. Please download the sample attached "MB file from this article and open with MapBasic. 

The sample table referenced refers to "Roads_100K.TAB" being used with the .MB.

2. Please make a copy of the user polygon table and change the name of the table to match the sample table name to "Roads_100K.TAB". 

In MapInfo Professional, users must know the max number of segments (sides) of all polygons before compiling the MapBasic code. (If a polygon has five sides in total then five segments will be added to the .MB plus SEGM10.

The Polygon Table Structure must be edited with the number of segments for each side. 

(Table > Maintenance > Table Structure)

3. When modifying the polygon table structure, add the additional fields with the length segment fields called SEGM1, SEGM2, SEGM3, SEGM4 and SEGM10 with an integer type. 

SEGM10 reads the length of the 10th line segment – this is used to make sure to included a line segment that might be in the object.

This file updates five columns of a table with the length of the 1st, 2nd, 3rd, 4th and 10th line segment of the records. 

4. In MapBasic compile the current file in MapBasic 15.0 once the polygon table is modified correctly. Then the MapBasic MBX will be created and ready to use.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Resolution Steps to update length for each polygon:

1. Convert Polygons to Polylines > Right click on Table name in Layer Control and Left click on Select all from Table name.
2. Object > Convert to Polylines > Save Table. 
3. Run MapBasic MBX to find length of all sides. 
4. Browse results of table for all length/sides of the polygons. 

Users can now browse the polygon table and see all the line segments updated with each segment length line segment. 

Environment Details

Product affected: MapInfo Professional™, Mapbasic™
Version Comments:
- 06/23/2016 MA057WI edited solution.

Downloads

  • No Downloads