GXPLY class

class GXPLY(handle=0)[source]

GXPLY class.

The GXPLY object contains the definitions for one or more polygons, and does import and export of polygon files.

__init__(handle=0)[source]

Initialize self. See help(type(self)) for accurate signature.

add_polygon(vv_x, vv_y)[source]

Add a polygon to the polygon file.

Parameters

New in version 5.0.

License: Geosoft Open License

add_polygon_ex(vv_x, vv_y, exclude)[source]

Add a polygon to the polygon file.

Parameters

New in version 5.0.

License: Geosoft Open License

area()[source]

Compute the Area of a polygon

Returns

Area of a polygon

Return type

float

New in version 5.1.3.

License: Geosoft Open License

Note: Excluded polygons have negative area.

change_ipj(ipj)[source]

Set the projection.

Parameters

ipj (GXIPJ) – GXIPJ to place in the GXPLY

New in version 5.0.5.

License: Geosoft Open License

Note: The GXPLY is re-projected to the new projection.

clear()[source]

Clear/remove all polygons from the GXPLY.

New in version 5.1.8.

License: Geosoft Open License

clip_area(min_x, min_y, max_x, max_y)[source]

Clip a polygon to an area

Parameters
  • min_x (float) – Min X

  • min_y (float) – Min Y

  • max_x (float) – Max X

  • max_y (float) – Max y

Returns

PLY_CLIP constants

Return type

int

New in version 5.1.3.

License: Geosoft Open License

clip_line_int(min_x, min_y, max_x, max_y, vv, inc, first)[source]

Clips a line in or out of the polygons for intersections (GS_DOUBLE). Intersections are returned as fiducials down the line stored in GXVV starting at the first point of the line. Examples: No intersection: PLY_LINE_CLIP_OUTSIDE, 0 intersections Starts outside, ends inside: PLY_LINE_CLIP_OUTSIDE, 1 intersection Starts outside, intersects then ends inside or outside: PLY_LINE_CLIP_OUTSIDE, 2 intersections Starts inside, ends inside : PLY_LINE_CLIP_INSIDE, 1 intersection (gives end-of-line) Starts inside, ends outside : PLY_LINE_CLIP_INSIDE, 1 intersection

Parameters
  • min_x (float) – Min X of line to clip

  • min_y (float) – Min Y of line to clip

  • max_x (float) – Max X of line to clip

  • max_y (float) – Max y of line to clip

  • vv (GXVV) – DOUBLE GXVV holding intersection fids

  • inc (float) – Data element increment (precision)

  • first (int_ref) – First point value (PLY_LINE_CLIP constants value)

Returns

0, Terminates on error (you can ignore this value)

Return type

int

New in version 6.3.

License: Geosoft Open License

clip_ply(pply_b, pply_c)[source]

Clip one polygon against another

Parameters
  • pply_b (GXPLY) – Polygon B

  • pply_c (GXPLY) – Resulting clipped region

Returns

PLY_CLIP constants

Return type

int

New in version 5.1.3.

License: Geosoft Open License

Note: Resulting clipped polygon only has inclusive regions of the clipped area. Exclusion polygons are treated as included areas.

clip_point(x, y)[source]

Clips a point in or out of the polygon. Point is inside: PLY_POINT_CLIP_INSIDE Point is outside: PLY_POINT_CLIP_OUTSIDE An error occurred: PLY_POINT_CLIP_ERROR

Parameters
  • x (float) – Point X

  • y (float) – Point Y

Returns

PLY_POINT_CLIP constants

Return type

int

New in version 9.6.

License: Geosoft Open License

combine(srce, exclude)[source]

Combines two GXPLY Object with another

Parameters
  • srce (GXPLY) – Source

  • exclude (int) – Make all the polygons copied excluded? - if not they will be copied as they are.

New in version 9.5.

License: Geosoft Open License

copy(srce)[source]

Copies one GXPLY Object to another

Parameters

srce (GXPLY) – Source

New in version 5.0.

License: Geosoft Open License

classmethod create()[source]

Creates a Polygon Object.

Returns

GXPLY Handle

Return type

GXPLY

New in version 5.0.

License: Geosoft Open License

classmethod create_s(bf)[source]

Create an GXPLY Object from a GXBF

Parameters

bf (GXBF) – GXBF to serialize from

Returns

GXPLY Handle

Return type

GXPLY

New in version 5.1.

License: Geosoft Open License

extent(min_x, min_y, max_x, max_y)[source]

Get the extent of the current polygon.

Parameters

New in version 5.0.

License: Geosoft Open License

Note: If there are no polygons in the GXPLY object, returns dummies.

get_description(desc)[source]

Get the GXPLY description string

Parameters

desc (str_ref) – Polygon description

New in version 5.1.

License: Geosoft Open License

get_ipj(ipj)[source]

Get the projection.

Parameters

ipj (GXIPJ) – GXIPJ in which to place the GXPLY projection

New in version 5.0.5.

License: Geosoft Open License

get_polygon(vv_x, vv_y, poly)[source]

Get a polygon from the GXPLY

Parameters

New in version 5.0.

License: Geosoft Open License

get_polygon_ex(vv_x, vv_y, poly, exclude)[source]

Get a polygon from the GXPLY

Parameters
  • vv_x (GXVV) – X GXVV.

  • vv_y (GXVV) – Y GXVV.

  • poly (int) – Polygon number

  • exclude (int_ref) – TRUE if exclusion polygon

New in version 5.0.

License: Geosoft Open License

is_null()[source]

Check if this is a null (undefined) instance

Returns

True if this is a null (undefined) instance, False otherwise.

Return type

bool

is_valid()[source]

Ensure a polygon is valid

Return type

int

New in version 9.5.

License: Geosoft Open License

load_table(table)[source]

Loads Polygons from a Polygon file.

Parameters

table (str) – Name of the polygon file File contains coordinates of one or more polygons

New in version 5.0.

License: Geosoft Open License

classmethod null()[source]

A null (undefined) instance of GXPLY

Returns

A null GXPLY

Return type

GXPLY

num_poly()[source]

Get the number of polygons.

Returns

Number of polygons in the GXPLY.

Return type

int

New in version 5.0.

License: Geosoft Open License

rectangle(min_x, min_y, max_x, max_y)[source]

Creates a polygon from a rectangular area.

Parameters
  • min_x (float) – Min X

  • min_y (float) – Min Y

  • max_x (float) – Max X

  • max_y (float) – Max Y

New in version 5.0.5.

License: Geosoft Open License

rotate(x, y, rot)[source]

Rotate a polygon about a point.

Parameters
  • x (float) – Rotation point, X

  • y (float) – Rotation point, Y

  • rot (float) – Rotation angle, CCW in degrees

New in version 5.0.

License: Geosoft Open License

save_table(table)[source]

Save Polygons to a Polygon file.

Parameters

table (str) – Name of the polygon file

New in version 5.0.

License: Geosoft Open License

serial(bf)[source]

Serialize an GXPLY to a GXBF

Parameters

bf (GXBF) – GXBF to serialize to

New in version 5.1.

License: Geosoft Open License

set_description(desc)[source]

Set the GXPLY description string

Parameters

desc (str) – Polygon description

New in version 5.1.

License: Geosoft Open License

set_ipj(ipj)[source]

Set the projection.

Parameters

ipj (GXIPJ) – GXIPJ to place in the GXPLY

New in version 5.0.5.

License: Geosoft Open License

Note: This changes the projection information only.

thin(thin)[source]

Thin polygons to a desired resolution

Parameters

thin (float) – Thining resolution

New in version 5.1.3.

License: Geosoft Open License

Note: Points on the polygon that deviate from a line drawn between neighboring points by more than the thining resolution will be removed.

PLY_CLIP constants

Polygon clipping mode

PLY_CLIP_NO_INTERSECT

The polygons do not intersect

gxapi.PLY_CLIP_NO_INTERSECT = 0
PLY_CLIP_INTERSECT

The polygons do intersect

gxapi.PLY_CLIP_INTERSECT = 1
PLY_CLIP_A_IN_B

Polygon A is completely inside polygon B

gxapi.PLY_CLIP_A_IN_B = 2
PLY_CLIP_B_IN_A

Polygon B is completely inside polygon A

gxapi.PLY_CLIP_B_IN_A = 3

PLY_POINT_CLIP constants

Polygon point clipping mode

PLY_POINT_CLIP_INSIDE

The point is inside the polygon

gxapi.PLY_POINT_CLIP_INSIDE = 0
PLY_POINT_CLIP_OUTSIDE

The point is outside the polygon

gxapi.PLY_POINT_CLIP_OUTSIDE = 1
PLY_POINT_CLIP_ERROR

An error occurred

gxapi.PLY_POINT_CLIP_ERROR = 2

PLY_LINE_CLIP constants

Polygon line clip indicator

PLY_LINE_CLIP_INSIDE

The start point of the line is inside

gxapi.PLY_LINE_CLIP_INSIDE = 0
PLY_LINE_CLIP_NO_INTERSECT

This name is a misnomer - it should have been PLY_LINE_CLIP_INSIDE, but is retained to support legacy code

gxapi.PLY_LINE_CLIP_NO_INTERSECT = 0
PLY_LINE_CLIP_OUTSIDE

The start point of the line is outside

gxapi.PLY_LINE_CLIP_OUTSIDE = 1
PLY_LINE_CLIP_ERROR

Error

gxapi.PLY_LINE_CLIP_ERROR = 2