Perimeter() function - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Purpose

Returns the perimeter of a graphical object. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

Perimeter( obj_expr, unit_name ) 

obj_expr is an object expression.

unit_name is a string representing the name of a distance unit (for example, "km").

Return Value

Float

Description

The Perimeter() function calculates the perimeter of the obj_expr object. The Perimeter() function is defined for the following object types: ellipses, rectangles, rounded rectangles, and polygons. Other types of objects have perimeter measurements of zero.

The Perimeter() function returns a length measurement in the units specified by the unit_name parameter; for example, to obtain a length in miles, specify "mi" as the unit_name parameter. See Set Distance Units statement for the list of valid unit names.

The Perimeter() function returns approximate results when used on rounded rectangles. MapBasic calculates the perimeter of a rounded rectangle as if the object were a conventional rectangle. For the most part, MapInfo Pro performs a Cartesian or Spherical operation. Generally, a spherical operation is performed unless the coordinate system is nonEarth, in which case, a Cartesian operation is performed.

Example

The following example shows how you can use the Perimeter() function to determine the perimeter of a particular geographic object.

Dim perim As Float
Open Table "world"
Fetch First From world
perim = Perimeter(world.obj, "km")

The variable perim now contains the perimeter of the polygon that's attached to the first record in the World table.

You can also use the Perimeter() function within the Select statement. The following Select statement extracts information from the States table, and stores the results in a temporary table called Results.

Because the Select statement includes the Perimeter() function, the Results table will include a column showing each state's perimeter.

Open Table "states"
Select state, Perimeter(obj, "mi")
	From states 
	Into results 

See Also:

Area() function, ObjectLen() function, Set Distance Units statement