GXSHP class¶
- class GXSHP(handle=0)[source]¶
GXSHP class.
The
GXSHPclass 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
GXSHPobject.New in version 7.2.
License: Geosoft Open License
Note: The currently stored
GXSHPitem and data are written to theGXSHPgeometry 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
GXSHPobject- Parameters:
name (str) – File name
type (int) – SHP_GEOM_TYPE constants
- Returns:
GXSHPobject- 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_POINTset_pointSHP_GEOM_TYPE_ARCset_arcSHP_GEOM_TYPE_POLYGONset_polygonSHP_GEOM_TYPE_POINTZset_point_zSHP_GEOM_TYPE_ARCZset_arc_zSHP_GEOM_TYPE_POLYGONZset_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
GXSHPobjectNew 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_ARCfiles.
- 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_ARCZfiles.
- 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
GXSHPobject’s projection.New in version 6.3.
License: Geosoft Open License
Note: If the
GXSHPobject 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_POINTfiles.
- 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_POINTZfiles.
- 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_POLYGONfiles.
- 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_POLYGONZfiles.
- 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
GXSHPobject’s geometry type.- Returns:
The
GXSHPobject’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
GXSHPitem and data are written to theGXSHPgeometry 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