GXSHP class¶
- class GXSHP(handle=0)[source]¶
GXSHP class.
The
GXSHP
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(field, dec)[source]¶
Add a REAL type data field to a shape file
- Parameters:
field (str) – Field name
dec (int) – Number of decimal places
- Returns:
Index of the new field
- Return type:
int
New in version 6.3.
License: Geosoft Open License
Note: The returned field index should be used with the SetXXX_SHP functions to set individual data values.
- add_int_field(field)[source]¶
Add an INT type data field to a shape file
- Parameters:
field (str) – Field name
- Returns:
Index of the new field
- Return type:
int
New in version 6.3.
License: Geosoft Open License
Note: The returned field index should be used with the SetXXX_SHP functions to set individual data values.
- add_string_field(field, width)[source]¶
Add a string type data field to a shape file
- Parameters:
field (str) – Field name
width (int) – Maximum number of characters in the string
- Returns:
Index of the new field
- Return type:
int
New in version 6.3.
License: Geosoft Open License
Note: The returned field index should be used with the SetXXX_SHP functions to set individual data values.
- append_item()[source]¶
Append the current item and data to an old
GXSHP
object.New in version 7.2.
License: Geosoft Open License
Note: The currently stored
GXSHP
item and data are written to theGXSHP
geometry and data files. (If no data fields have been defined, then the data file is not written).
- classmethod create(name, type)[source]¶
Create a new
GXSHP
object- Parameters:
name (str) – File name
type (int) – SHP_GEOM_TYPE constants
- Returns:
GXSHP
object- Return type:
New in version 6.3.
License: Geosoft Open License
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
set_point
SHP_GEOM_TYPE_ARC
set_arc
SHP_GEOM_TYPE_POLYGON
set_polygon
SHP_GEOM_TYPE_POINTZ
set_point_z
SHP_GEOM_TYPE_ARCZ
set_arc_z
SHP_GEOM_TYPE_POLYGONZ
set_polygon_z
- find_field(field)[source]¶
Find the index for a data field.
- Parameters:
field (str) – Field name
- Returns:
The index, -1 if not found.
- Return type:
int
New in version 6.3.
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
- max_id_num()[source]¶
Get the max ID number.
- Returns:
The max ID number.
- Return type:
int
New in version 7.2.
License: Geosoft Open License
- num_fields()[source]¶
Get the field number.
- Returns:
The field number.
- Return type:
int
New in version 7.2.
License: Geosoft Open License
- num_records()[source]¶
Get the record number.
- Returns:
The record number.
- Return type:
int
New in version 7.2.
License: Geosoft Open License
- classmethod open(name)[source]¶
Open an old
GXSHP
objectNew in version 7.2.
License: Geosoft Open License
- set_arc(vv_x, vv_y)[source]¶
Write an XY arc (polyline) item.
New in version 6.3.
License: Geosoft Open License
Note: Can ONLY be used for
SHP_GEOM_TYPE_ARC
files.
- set_arc_z(vv_x, vv_y, vv_z)[source]¶
Write an XYZ arc (polyline) item.
New in version 6.3.
License: Geosoft Open License
Note: Can ONLY be used for
SHP_GEOM_TYPE_ARCZ
files.
- set_double(index, val)[source]¶
Set a data value to a real.
- Parameters:
index (int) – Data field index
val (float) – Input real value
New in version 6.3.
License: Geosoft Open License
Note: The input value is converted to the field’s data type.
- set_int(index, val)[source]¶
Set a data value to a int.
- Parameters:
index (int) – Data field index
val (int) – Input int value
New in version 6.3.
License: Geosoft Open License
Note: The input value is converted to the field’s data type.
- set_ipj(ipj)[source]¶
Set a
GXSHP
object’s projection.New in version 6.3.
License: Geosoft Open License
Note: If the
GXSHP
object has a projection, and it is notIPJ_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(x, y)[source]¶
Write an XY point item.
- Parameters:
x (float) – X location
y (float) – Y location
New in version 6.3.
License: Geosoft Open License
Note: Can ONLY be used for
SHP_GEOM_TYPE_POINT
files.
- set_point_z(x, y, z)[source]¶
Write an XYZ point item.
- Parameters:
x (float) – X location
y (float) – Y location
z (float) – Z location
New in version 6.3.
License: Geosoft Open License
Note: Can ONLY be used for
SHP_GEOM_TYPE_POINTZ
files.
- set_polygon(vv_x, vv_y, inclusive)[source]¶
Write an XY polygon item.
- Parameters:
New in version 6.3.
License: Geosoft Open License
Note: Can ONLY be used for
SHP_GEOM_TYPE_POLYGON
files.
- set_polygon_z(vv_x, vv_y, vv_z, inclusive)[source]¶
Write an XYZ polygon item.
- Parameters:
New in version 6.3.
License: Geosoft Open License
Note: Can ONLY be used for
SHP_GEOM_TYPE_POLYGONZ
files.
- set_string(index, str_val)[source]¶
Set a data value to a string.
- Parameters:
index (int) – Data field index
str_val (str) – Input string value
New in version 6.3.
License: Geosoft Open License
Note: The input string is converted to the field’s data type.
- type()[source]¶
Get the
GXSHP
object’s geometry type.- Returns:
The
GXSHP
object’s geometry type (SHP_GEOM_TYPE constants)- Return type:
int
New in version 7.2.
License: Geosoft Open License
- write_item()[source]¶
Output the current item and data.
New in version 6.3.
License: Geosoft Open License
Note: The currently stored
GXSHP
item and data are written to theGXSHP
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