CalcEnclosedArea

globalmapper.CalcEnclosedArea(GM_Point_t_array aPtList, int aNumPoints, GM_Projection_t aProj) GM_Error_t32, float[source]

Calculates the enclosed area of a region in square meters. The coordinates in aPtList are in the projection defined by aProj. If None is passed for aProj then the current global projection as returned by GetProjection is assumed.

Parameters:
  • aPtList (GM_Point_t_array) – list of points defining area

  • aNumPoints (int) – the size of aPtList

  • aProj (GM_Projection_t) – projection of points in list (use None for current projection returned by GetProjection)

Returns:

Error Code

Return type:

GM_Error_t32

Returns:

Enclosed area in square meters

Return type:

float

Example

The following is an example of CalcEnclosedArea.

# Values that will be used to generate point objects
data_list = [-26, 16, -25.9, 16, -25.9, 15.9, -26, 15.9]
pt_list = []
# Create the points
for i in range(0, len(data_list), 2):
    pt = gm.GM_Point_t(data_list[i], data_list[i + 1])
    pt_list.append(pt)

# Turn the point list into an array
pt_array = gm.GM_Point_t_array(len(pt_list))
for j in range(len(pt_list)):
    pt_array[j] = pt_list[j]

# Load a WGS84 projection
err_LoadProjectionFromEPSGCode, proj = gm.LoadProjectionFromEPSGCode(4326)
err_CalcEnclosedArea, area = gm.CalcEnclosedArea(pt_array, len(pt_list), proj)
print("The enclosed area is", area, "square meters.")