Geometric Functions

These geometric functions are available for use in formulas in Cartographica. To use them, you must always specify geometry.function(parameters). For example, to obtain the area of the current geometry (valid only for polygons), you would use "geometry.area()".

Some of the geometric functions return special object types (Rect and Point) that must be further operated upon in order to export the values.

Point objects consist of an x and y coordinate, which are accessed by appending ".x" or ".y" respectively to the function result.  For example, "geometry.centroid().x" and "geometry.centroid().y".

Rect objects consist of the x and y origin and the width and height, which are accessed by appending ".x", ".y", ".width", or ".height" respectively to the function result.

Each of the geometric functions can return their values in the CRS for the map (default) or the CRS for the geometry's layer (set `layerCRS` to 1).


float geometry.area([bool layerCRS])

Returns the area in the current coordinate system units, using either the map coordinates (layerCRS is 0 or not present) or the original layer coordinates (layerCRS is 1).

This function is only available for polygons.

float geometry.length([bool layerCRS])

Returns the length in the current coordinate system units, using either the map coordinates (layerCRS is 0 or not present) or the original layer coordinates (layerCRS is 1).

This function is only available for polygons and lines

Rect geometry.bbox([bool layerCRS])

Returns the Rect of the bounding box of the current geometry using either the map coordinates (layerCRS is 0 or not present) or the original layer coordinates (layerCRS is 1).

The return value is a structure containing x, y, width, and height. To access each individual element, use the dot notation: geometry.bbox().x to retrieve the x coordinate, for example.

Point geometry.midpoint([bool layerCRS])

Returns the Point representing the midpoint of the line in the current coordinate system, using either the map coordinates (layerCRS is 0 or not present) or the original layer coordinates (layerCRS is 1).

This function is only available for lines.

Point geometry.centroid([bool layerCRS])

Returns the Point representing the centroid of the feature in the current coordinate system, using either the map coordinates (layerCRS is 0 or not present) or the original layer coordinates (layerCRS is 1).

This function is only for points, multipoints, and polygons.