SphericalArea( ) 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 area using as calculated in a Latitude/Longitude non-projected coordinate system using great circle based algorithms. You can call this function from the MapBasic window in MapInfo Pro.

Syntax

SphericalArea( obj_expr, unit_name )

obj_expr is an object expression.

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

Return Value

Float

Description

The SphericalArea( ) function returns the area of the geographical object specified by obj_expr. The function returns the area measurement in the units specified by the unit_name parameter; for example, to obtain an area in acres, specify "acre" as the unit_name parameter. See Set Area Units statement for the list of available unit names.

The SphericalArea( ) function will always return the area 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.

Only regions, ellipses, rectangles, and rounded rectangles have any area. By definition, the SphericalArea( ) of a point, arc, text, line, or polyline object is zero. The SphericalArea( ) function returns approximate results when used on rounded rectangles. MapBasic calculates the area of a rounded rectangle as if the object were a conventional rectangle.

Examples

The following example shows how the SphericalArea( ) function can calculate the area of a single geographic object. Note that the expression tablename.obj (as in states.obj) represents the geographical object of the current row in the specified table.

Dim f_sq_miles As Float
Open Table "states" 
Fetch First From states
f_sq_miles = Area(states.obj, "sq mi")

You can also use the SphericalArea( ) function within the Select statement, as shown in the following example.

Select state, SphericalArea(obj, "sq km") 
	From states Into results 

See Also:

CartesianArea( ) function, SphericalArea( ) function