pyisg#

Library reading/writing the ISG 2.0 format.

This provides APIs, such as load(), loads(), dump() and dumps().

import pyisg

# serialize to ISG 2.0 format str to dict
with open("file.isg") as fs:
    obj = pyisg.load(fs)

# deserialize to ISG 2.0 format str
s = pyisg.dumps(obj)

One can install pyisg from PyPI

pip install pyisg
Licence

MIT or Apache-2.0

Reference

Specification: https://www.isgeoid.polimi.it/Geoid/format_specs.html

pyisg package#

Submodules#

Module contents#

Provides serialize/deserialize API of ISG 2.0 format.

class pyisg.ISGFormatType#

Bases: TypedDict

Type of ISG data dict.

comment: str#
header: HeaderType#
data: list[list[float | None]] | list[tuple[DmsCoordType | float, DmsCoordType | float, float]]#
pyisg.loads(s: str) ISGFormatType#

Deserialize ISG 2.0 format str obj to dict obj.

Parameters:

s – ISG 2.0 format str obj

Returns:

dict of ISG data

Raises:

DeserializeError – deserialization failed

pyisg.load(fp: TextIO) ISGFormatType#

Deserialize ISG 2.0 file-like obj to dict obj.

Parameters:

fp – file-like obj of ISG 2.0 format data

Returns:

dict of ISG data

Raises:

DeserializeError – deserialization failed

pyisg.dumps(obj: Any) str#

Serialize ISGFormatType-like obj into str obj.

Parameters:

objISGFormatType-like obj (Mapping-like obj)

Raises:
  • SerializeError – serialization failed

  • pyo3_runtime.PanicException – data has None even when nodata is None

pyisg.dump(obj: Any, fp: TextIO) int#

Serialize ISGFormatType like obj into file-like obj.

Parameters:
  • objISGFormatType-like obj (Mapping-like obj)

  • fp – output file-like obj

Returns:

The number of characters written

Raises:
  • SerializeError – serialization failed

  • pyo3_runtime.PanicException – data has None even when nodata is None

exception pyisg.ISGEncodeError#

Bases: ValueError

Error of dump() and dumps().

exception pyisg.ISGDecodeError#

Bases: ValueError

Error of load() and loads().

pyisg.types module#

Provides definition of types.

class pyisg.types.ISGFormatType#

Bases: TypedDict

Type of ISG data dict.

comment: str#
header: HeaderType#
data: list[list[float | None]] | list[tuple[DmsCoordType | float, DmsCoordType | float, float]]#
class pyisg.types.HeaderType#

Bases: TypedDict

Type of Header dict.

model_name: str | None#
model_year: str | None#
model_type: ModelTypeType | None#
data_type: DataTypeType | None#
data_units: DataUnitsType | None#
data_format: Required[DataFormatType]#
data_ordering: DataOrderingType | None#
ref_ellipsoid: str | None#
ref_frame: str | None#
height_datum: str | None#
tide_system: TideSystemType | None#
coord_type: Required[CoordTypeType]#
coord_units: Required[CoordUnitsType]#
map_projection: str | None#
EPSG_code: str | None#
lat_min: CoordType | None#
lat_max: CoordType | None#
north_min: CoordType | None#
north_max: CoordType | None#
lon_min: CoordType | None#
lon_max: CoordType | None#
east_min: CoordType | None#
east_max: CoordType | None#
delta_lat: CoordType | None#
delta_lon: CoordType | None#
delta_north: CoordType | None#
delta_east: CoordType | None#
nrows: Required[int]#
ncols: Required[int]#
nodata: float | None#
creation_date: CreationDateType | None#
ISG_format: Required[str]#
class pyisg.types.CreationDateType#

Bases: TypedDict

Type of creation date.

year: int#
month: int#
day: int#
class pyisg.types.DmsCoordType#

Bases: TypedDict

Type of DMS coordinate.

degree: int#
minutes: int#
second: int#

Indices and tables#