SphericalPerimeter() 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

SphericalPerimeter( 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 SphericalPerimeter() function calculates the perimeter of the obj_expr object. The SphericalPerimeter() function is defined for the following object types: ellipses, rectangles, rounded rectangles, and polygons. Other types of objects have perimeter measurements of zero. The SphericalPerimeter() 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 SphericalPerimeter() function always returns a value as calculated in a Latitude/Longitude non-projected coordinate system using spherical algorithms. A value of -1 will be returned for data that is in a NonEarth coordinate system since this data cannot be converted into a Latitude/longitude coordinate system. The SphericalPerimeter() 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.

Example

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

Dim perim As Float
Open Table "world"
Fetch First From world
perim = SphericalPerimeter(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 SphericalPerimeter() 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 SphericalPerimeter() 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:

CartesianPerimeter() function, Perimeter() function