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.-
add_polygon
(vv_x, vv_y)[source]¶ Add a polygon to the polygon file.
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.
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.
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
- 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 inGXVV
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
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
- Returns
- 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
- 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.
New in version 5.0.
License: Geosoft Open License
-
classmethod
create_s
(bf)[source]¶ Create an
GXPLY
Object from aGXBF
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.
New in version 5.0.5.
License: Geosoft Open License
-
get_polygon
(vv_x, vv_y, poly)[source]¶ Get a polygon from the
GXPLY
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
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
-
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]¶ -
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.
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_POINT_CLIP constants¶
Polygon point clipping mode
PLY_LINE_CLIP constants¶
Polygon line clip indicator
-
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¶
-