GXSHP class

class geosoft.gx.GXSHP
The SHP class is used to create ESRI shape files.

Note:

Shape files contain a single "geometry" type, e.g.
points, arcs or polygons. They may be accompanied by
a DBF file containing attribute data.
add_double_field((str)arg1, (int)arg2) → int:
Add a REAL type data field to a shape file
Parameters:
  • arg1 (str) – field name
  • arg2 (int) – number of decimal places
Returns:

Index of the new field

Return type:

int

New in version 6.3.0.

Note:

The returned field index should be used with the SetXXX_SHP
functions to set individual data values.
add_int_field((str)arg1) → int:
Add an INT type data field to a shape file
Parameters:arg1 (str) – field name
Returns:Index of the new field
Return type:int

New in version 6.3.0.

Note:

The returned field index should be used with the SetXXX_SHP
functions to set individual data values.
add_string_field((str)arg1, (int)arg2) → int:
Add a string type data field to a shape file
Parameters:
  • arg1 (str) – field name
  • arg2 (int) – Maximum number of characters in the string
Returns:

Index of the new field

Return type:

int

New in version 6.3.0.

Note:

The returned field index should be used with the SetXXX_SHP
functions to set individual data values.
append_item() → None:
Append the current item and data to an old SHP object.
Returns:Nothing
Return type:None

New in version 7.2.0.

Note:

The currently stored SHP item and data are written to the
SHP geometry and data files. (If no data fields have been
defined, then the data file is not written).
static create((GXContext)ctx, (str)arg1, (int)arg2) → GXSHP:
Create a new SHP object
Parameters:
Returns:

SHP object

Return type:

geosoft.gx.GXSHP

New in version 6.3.0.

Note:

The file name is used to create the various files. The
file type and extension are added:

e.g. "filename.shp",
     "filename.dbf"

The following geometry types are currently supported:

Type                    Required geometry function.

SHP_GEOM_TYPE_POINT     geosoft.gx.GXSHP.set_point()
SHP_GEOM_TYPE_ARC       geosoft.gx.GXSHP.set_arc()
SHP_GEOM_TYPE_POLYGON   geosoft.gx.GXSHP.set_polygon()

SHP_GEOM_TYPE_POINTZ    geosoft.gx.GXSHP.set_point_z()
SHP_GEOM_TYPE_ARCZ      geosoft.gx.GXSHP.set_arc_z()
SHP_GEOM_TYPE_POLYGONZ  geosoft.gx.GXSHP.set_polygon_z()
find_field((str)arg1) → int:
Find the index for a data field.
Parameters:arg1 (str) – field name
Returns:The index, -1 if not found.
Return type:int

New in version 6.3.0.

is_null() → bool

Check if the instance of geosoft.gx.GXSHP is null (undefined)

Returns:True if this is a null instance of geosoft.gx.GXSHP, False otherwise.
Return type:bool`
max_id_num() → int:
Get the max ID number.
Returns:The max ID number.
Return type:int

New in version 7.2.0.

static null() → GXSHP

A null (undefined) instance of geosoft.gx.GXSHP

Returns:A null geosoft.gx.GXSHP
Return type:geosoft.gx.GXSHP
num_fields() → int:
Get the field number.
Returns:The field number.
Return type:int

New in version 7.2.0.

num_records() → int:
Get the record number.
Returns:The record number.
Return type:int

New in version 7.2.0.

static open((GXContext)ctx, (str)arg1) → GXSHP:
Open an old SHP object
Parameters:
Returns:

SHP object

Return type:

geosoft.gx.GXSHP

New in version 7.2.0.

set_arc((GXVV)arg1, (GXVV)arg2) → None:
Write an XY arc (polyline) item.
Parameters:
Returns:

Nothing

Return type:

None

New in version 6.3.0.

Note:

Can ONLY be used for SHP_GEOM_TYPE_ARC files.
set_arc_z((GXVV)arg1, (GXVV)arg2, (GXVV)arg3) → None:
Write an XYZ arc (polyline) item.
Parameters:
Returns:

Nothing

Return type:

None

New in version 6.3.0.

Note:

Can ONLY be used for SHP_GEOM_TYPE_ARCZ files.
set_double((int)arg1, (float)arg2) → None:
Set a data value to a real.
Parameters:
  • arg1 (int) – data field index
  • arg2 (float) – input real value
Returns:

Nothing

Return type:

None

New in version 6.3.0.

Note:

The input value is converted to the field's data type.
set_int((int)arg1, (int)arg2) → None:
Set a data value to a int.
Parameters:
  • arg1 (int) – data field index
  • arg2 (int) – input int value
Returns:

Nothing

Return type:

None

New in version 6.3.0.

Note:

The input value is converted to the field's data type.
set_ipj((GXIPJ)arg1) → None:
Set a SHP object's projection.
Parameters:arg1 (geosoft.gx.GXIPJ) – input IPJ
Returns:Nothing
Return type:None

New in version 6.3.0.

Note:

If the SHP object has a projection, and it
is not IPJ_TYPE_NONE, then it will be output
to a file with the .prj extension when the
first object is output.
This function should be called BEFORE the first
object is written.
set_point((float)arg1, (float)arg2) → None:
Write an XY point item.
Parameters:
  • arg1 (float) – X location
  • arg2 (float) – Y location
Returns:

Nothing

Return type:

None

New in version 6.3.0.

Note:

Can ONLY be used for SHP_GEOM_TYPE_POINT files.
set_point_z((float)arg1, (float)arg2, (float)arg3) → None:
Write an XYZ point item.
Parameters:
  • arg1 (float) – X location
  • arg2 (float) – Y location
  • arg3 (float) – Z location
Returns:

Nothing

Return type:

None

New in version 6.3.0.

Note:

Can ONLY be used for SHP_GEOM_TYPE_POINTZ files.
set_polygon((GXVV)arg1, (GXVV)arg2, (bool)arg3) → None:
Write an XY polygon item.
Parameters:
  • arg1 (geosoft.gx.GXVV) – X locations
  • arg2 (geosoft.gx.GXVV) – Y locations
  • arg3 (bool) – bool True for outer ring polygon (inclusive/island), False for inner ring (exclusive/hole)
Returns:

Nothing

Return type:

None

New in version 6.3.0.

Note:

Can ONLY be used for SHP_GEOM_TYPE_POLYGON files.
set_polygon_z((GXVV)arg1, (GXVV)arg2, (GXVV)arg3, (bool)arg4) → None:
Write an XYZ polygon item.
Parameters:
  • arg1 (geosoft.gx.GXVV) – X locations
  • arg2 (geosoft.gx.GXVV) – Y locations
  • arg3 (geosoft.gx.GXVV) – Z locations
  • arg4 (bool) – bool True for outer ring polygon (inclusive/island), False for inner ring (exclusive/hole)
Returns:

Nothing

Return type:

None

New in version 6.3.0.

Note:

Can ONLY be used for SHP_GEOM_TYPE_POLYGONZ files.
set_string((int)arg1, (str)arg2) → None:
Set a data value to a string.
Parameters:
  • arg1 (int) – data field index
  • arg2 (str) – input string value
Returns:

Nothing

Return type:

None

New in version 6.3.0.

Note:

The input string is converted to the field's data type.
type() → int:
Get the SHP object's geometry type.
Returns:the SHP object’s geometry type (SHP_GEOM_TYPE constants)
Return type:int

New in version 7.2.0.

write_item() → None:
Output the current item and data.
Returns:Nothing
Return type:None

New in version 6.3.0.

Note:

The currently stored SHP item and data are written to the
SHP geometry and data files. (If no data fields have been
defined, then the data file is not written).

SHP_GEOM_TYPE constants

Shape file geometry types
gx.SHP_GEOM_TYPE_POINT = 1
Single (X, Y) point
gx.SHP_GEOM_TYPE_ARC = 3
Arc (polyline) multiple (X, Y) points.
gx.SHP_GEOM_TYPE_POLYGON = 5
Polygon. Multiple (X, Y) points.
gx.SHP_GEOM_TYPE_POINTZ = 11
Single (X, Y, Z) point
gx.SHP_GEOM_TYPE_ARCZ = 13
Arc (polyline) multiple (X, Y, Z) points.
gx.SHP_GEOM_TYPE_POLYGONZ = 15
Polygon. Multiple (X, Y, Z) points.