geosoft.gxpy.geometry submodule

Spatial geometric objects.

Classes
Geometry

base class for all geometries

Point

(x, y, z) point

Point2

pair of Point instances that define a line, or box, etc.

PPoint

multiple Point instances

Mesh

mesh surface made up of triangular faces defined by verticies

Note

Regression tests provide usage examples: geometry tests

class Geometry(coordinate_system=None, name=None, gxobj=None)[source]

Bases: object

Geometry base class for all geometries and spatial objects in Geosoft.

Parameters
Properties
Geometry.name

name for the geometry

Geometry.coordinate_system

spatial coordinate system of the x, y, z locations

Geometry.extent

spatial extent as a Point2

Geometry.extent_xyz

(min_x, min_y, min_z, max_x, max_y, max_z)

Geometry.extent_xy

(min_x, min_y, max_x, max_y)

Geometry.dimension

(dx, dy, dz) dimension

Geometry.dimension_xy

(dx, dy) dimension

Geometry.centroid

center point as a Point

Geometry.centroid_xyz

(x, y, z) location of the object center

Geometry.centroid_xy

(x, y) center

New in version 9.2.

__init__(coordinate_system=None, name=None, gxobj=None)[source]

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

property centroid

Object centroid as a Point instance.

property centroid_xy

Horizontal centroid as a tuple (x, y).

property centroid_xyz

Horizontal centroid as a tuple (x, y, z).

property coordinate_system

geosoft.gxpy.coordinate_system.Coordinate_system instance or None. Can be set.

property dimension

Object dimensions as tuple (dx, dy, dz)

property dimension_xy

Horizontal dimension as a tuple (dx, dy).

property extent

Object extent as a Point2 instance.

property extent_maximum

Maximum geometry extent as Point instance.

property extent_maximum_xy

Maximum horizontal extent as tuple (max_x, max_y).

property extent_maximum_xyz

Maximum geometry extent as tuple (x, y, z).

property extent_minimum

Minimum geometry extent as Point instance.

property extent_minimum_xy

Minimum horizontal extent as tuple (min_x, min_y).

property extent_minimum_xyz

Minimum geometry extent as tuple (x, y, z).

property extent_xy

Horizontal extent as a tuple (min_x, min_y, max_x, max_y).

property extent_xyz

Object extent as a tuple (xmin, ymin, zmin, xmax, ymax, zmax).

property gxobj

An associated gxapi object, or None.

property name

Spatial object name, can be set.

exception GeometryException(message)[source]

Bases: geosoft.GXRuntimeError

Exceptions from geosoft.gxpy.geometry.

class Mesh(mesh, coordinate_system=None, **kwargs)[source]

Bases: geosoft.gxpy.geometry.Geometry, collections.abc.Sequence

Mesh - set of triangular faces, which are indexes into verticies.

Parameters
  • mesh – (faces, verticies) that define a trangulated mesh surface. See below.

  • coordinate_system – coordinate system or None

  • kwargs – passed to base class Geometry

A mesh is a set of triangles, where each triangle has three indexes into a set of verticies. Verticies are defined by a set of (x, y, z) locations. A Mesh instance can be constructed from two arrays in the form (faces, verticies), or from two sets of geosoft.gxpy.vv.GXvv instances in the form ((f1vv, f2vv, f3vv), (xvv, yvv, zvv)). In array form, each array is shaped (-1, 3), with faces being an integer array that references vertexes in the float vertex array.

Operators supported: = + -, where ‘+’ can be used to combine two meshes or add a constant offset.

Iterating yields triangular faces as PPoint instances.

Example

import numpy as np
import geosoft.gxpy.geometry as gxgm
import geosoft.gxpy.vv as gxvv

# create from lists
faces = [[0, 1, 2],
         [0, 2, 3],
         [3, 2, 4]]
verticies = [[0, 0, 0],
             [5, 0, 0],
             [5, 5, 0],
             [0, 3, 5],
             [2.5, 2, 10]]
mesh = gxgm.Mesh((faces, verticies))

# create from numpy arrays
faces = np.array(faces, dtype=np.int32)
verticies = np.array(verticies, dtype=np.float64)
mesh = gxgm.Mesh((faces, verticies))

# create from vv
f1vv, f2vv, f3vv = gxvv.vvset_from_np(faces)
xvv, yvv, zvv = gxvv.vvset_from_np(verticies)
mesh = gxgm.Mesh(((f1vv, f2vv, f3vv), (xvv, yvv, zvv)))

New in version 9.3.1.

__init__(mesh, coordinate_system=None, **kwargs)[source]

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

copy()[source]

Return a copy

property extent

Volume extent as Point2.

New in version 9.3.1.

property faces

Faces as an integer numpy array, shape (n_faces, 3).

faces_vv()[source]

Return faces in geosoft.gxpy.vv.GXvv tuple (f1vv, f2vv, f3vv).

faces_vv_fast()[source]

Return faces in list (f1vv, f2vv, f3vv).

property length

Number of faces

point_array(unique=True)[source]

Return numpy array of face corner locations.

Parameters

uniqueTrue to limit to unique points, otherwise returns all points by unwinding each face. If unique the order will not be related to the faces.

New in version 9.3.1.

property pp

Verticies as a numpy array shaped (n_verticies, 3).

property verticies

Verticies as a float numpy array, shape (n_verticies, 3).

verticies_vv()[source]

Return verticies in geosoft.gxpy.vv.GXvv tuple (xvv, yvv, zvv).

verticies_vv_fast()[source]

Return verticies in list (xvv, yvv, zvv).

class PPoint(xyz, coordinate_system=None, z=0.0, name=None, **kwargs)[source]

Bases: geosoft.gxpy.geometry.Geometry, collections.abc.Sequence

Poly-Point class. Basic instance arithmetic and equality testing is supported.

Parameters
  • xyz – array-like: (p1, p2, …), ((x, y), …), ((x, y, z), …) or (vv_x, vv_y, [vv_z]). vv data is resampled to match the first vv.

  • coordinate_system – coordinate system or None

  • z – constant z value for (x, y) data, ignored for (x, y, z) data

  • kwargs – passed to base class Geometry

Operators supported: = + - * /

New in version 9.2.

Changed in version 9.3.1: added coordinate_system parameter

__init__(xyz, coordinate_system=None, z=0.0, name=None, **kwargs)[source]

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

copy()[source]

Return a copy

property extent

Volume extent as Point2 for (min, max).

New in version 9.2.

classmethod from_list(xyzlist, z=0.0)[source]

Deprecated since version 9.3: PPoint can create directly from a list

property length

number of points

make_xyz_vv()[source]

Return x, y and z as a set of geosoft.gxpy.vv.GXvv.

Returns

(xvv, yvv, zvv)

New in version 9.2.

classmethod merge(pp_list)[source]

Create a PPoint from a list of Point, ‘Point2` or PPoint instances or point arrays.

Parameters

pp_list – list of Point, ‘Point2` or PPoint instances or point arrays.

Returns

PPoint instance that contains all points

New in version 9.4.

property x

x array slice, can be set

property xy

(x, y) array slice, can be set

property xyz

xyz point array

property y

y array slice, can be set

property z

z array slice, can be set

class Point(p, coordinate_system=None, name=None, z=0.0, **kwargs)[source]

Bases: geosoft.gxpy.geometry.Geometry, collections.abc.Sequence

Spatial location (x,y,z). Basic instance arithmetic and equality testing is supported.

Parameters
  • p

    point in one of the following forms:

    Point instance, returns a copy

    (x, y [,z]) implied z is as defined by z=

    k makes a point (k, k, k)

  • coordinate_system – coordinate system or None

  • z – implied z if len(p) is 2.

  • kwargs – passed to base class Geometry

Iterates on [x, y, z]

Operators supported: = + - * /

New in version 9.2.

Changed in version 9.3.1: added coordinate_system parameter

__init__(p, coordinate_system=None, name=None, z=0.0, **kwargs)[source]

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

copy()[source]

Return a copy

property extent

Object extent as a Point2 instance.

property pp

Point as a numpy array shaped (1, 3)

property x

x value, can be set

property xy

(x, y), can be set

property xyz

(x, y, z), can be set

property y

y value, can be set

property z

z value, can be set

class Point2(p, coordinate_system=None, name=None, z=0, **kwargs)[source]

Bases: geosoft.gxpy.geometry.Geometry, collections.abc.Sequence

Two points, for a line, or a rectangle, or a cube. Basic instance arithmetic and equality testing is supported.

Parameters
  • p

    Points in one of the following forms:

    Point2 makes a copy in the required coordinate system

    (Point, Point)

    (x, y [, z]) two points at the same location

    ((x, y [, z]), (x, y [, z]))

    (x0, y0, x1, y1) implied z is 0

    (x0, y0, z0, x1, y1, z1)

  • coordinate_system – coordinate system or None

  • z – implied z value when only (x, y) is passed

  • kwargs – passed to base class Geometry

Iterates on two points [p0, p1].

Operators supported: = + - * /

Second operand may be a Point2 or a Point.

New in version 9.2.

Changed in version 9.3.1: added coordinate_system parameter

__init__(p, coordinate_system=None, name=None, z=0, **kwargs)[source]

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

copy()[source]

Return a copy

property extent

Extent as (xmin, ymin, zmin, xmax, ymax, zmax)

property pp

Point2 as a numpy array shaped (2, 3)

property x2

(x0, x1), can be set

property y2

(y0, y1), can be set

property z2

(z0, z1), can be set

extent_union(g1, g2)[source]

Return the spatial union of two spatial objects.

Parameters
  • g1 – extent (p0 < p1), returned extent will be in this coordinate system

  • g2 – second object

Returns

Point2 instance in the coordinate system of g1

New in version 9.3.1.

first_coordinate_system(geo_objects)[source]

Return the first found known coordinate system in the list

Parameters

geo_objects – objects as iterable

Returns

valid coordinate system or None if none found

New in version 9.3.1.