geoh5py.shared.conversion package

Submodules

geoh5py.shared.conversion.base module

class geoh5py.shared.conversion.base.BaseConversion[source]

Bases: ABC

classmethod copy_child_properties(input_entity: ObjectBase, output: ObjectBase, association: str, **kwargs)[source]

Copy child properties from the original entity to the new one.

Parameters:
  • input_entity – The input entity to convert.

  • output – The new entity.

  • association – Association of the children to copy.

classmethod validate_workspace(input_entity: ObjectBase, **kwargs) tuple[Workspace, dict][source]

Define the parent of the converter class if the parent is defined in the kwargs; and the workspace to use. :param input_entity: The input entity to convert. :return: a tuple containing the (parent, workspace)

classmethod verify_kwargs(input_entity, **kwargs) dict[source]

Verify if the kwargs are valid and update kwargs with core properties.

Parameters:
  • input_entity – The input entity to convert.

  • kwargs – Additional keyword arguments.

Returns:

A dictionary of the valid kwargs.

class geoh5py.shared.conversion.base.CellObjectConversion[source]

Bases: BaseConversion

Converter class from a :obj:geoh5py.objects.CellObject to a :obj:geoh5py.objects.Points.

classmethod to_points(input_entity: ObjectBase, copy_children=True, **kwargs) objects.Points[source]

Cell-based object conversion to Points

Parameters:

input_entity – The input entity to convert.

Returns:

A Points object.

geoh5py.shared.conversion.geo_image module

class geoh5py.shared.conversion.geo_image.GeoImageConversion[source]

Bases: BaseConversion

Convert a :obj:’geoh5py.objects.geo_image.GeoImage’ object.

static add_color_data(values: np.ndarray, output: Grid2D)[source]

Send the image color bands to data.

Parameters:
  • values – Input image values as an array of int.

  • output – the new :obj:’geoh5py.objects.grid2d.Grid2D’.

static add_data_2dgrid(geoimage: Image, output: Grid2D)[source]

Select the type of the image transformation. :param geoimage: :obj:’geoh5py.objects.geo_image.GeoImage’ object. :param output: the new :obj:’geoh5py.objects.grid2d.Grid2D’.

static add_gray_data(values: np.ndarray, output: Grid2D)[source]

Send the image as gray in the new :obj:’geoh5py.objects.grid2d.Grid2D’. :param values: Input image values as an array of int. :param output: the new :obj:’geoh5py.objects.grid2d.Grid2D’.

static convert_to_grid2d_reference(geoimage: GeoImage, grid2d_attributes) dict[source]

Extract the geographic information from the entity.

static to_grid2d(geoimage: GeoImage, mode: str | None, copy_children=True, **grid2d_kwargs) Grid2D[source]

Transform the :obj:’geoh5py.objects.image.Image’ to a :obj:’geoh5py.objects.grid2d.Grid2D’. :param geoimage: :obj:’geoh5py.objects.geo_image.GeoImage’ object. :param mode: The outgoing image mode option.

Returns:

the new :obj:’geoh5py.objects.grid2d.Grid2D’.

geoh5py.shared.conversion.grid2d module

class geoh5py.shared.conversion.grid2d.Grid2DConversion[source]

Bases: CellObjectConversion

Convert a :obj:’geoh5py.objects.grid2d.Grid2D’ object to a georeferenced :obj:’geoh5py.objects.geo_image.GeoImage’ object.

static compute_vertices(input_entity: Grid2D) np.ndarray[source]

Compute the vertices of the geoimage to create based on the properties of the grid and its angle. :param input_entity: The grid2D object to convert. :return: A numpy array of 4 points in x,y,z.

static convert_to_pillow(data: np.ndarray, mode: str | None = None) Image[source]

Convert the data from :obj:’np.array’ to :obj:’PIL.Image’ format.

static data_from_keys(input_entity: Grid2D, keys: list | str | int | UUID | Data, normalize: bool = True) np.ndarray[source]

Take a list of (or a unique) key to extract from the object, and create a :obj:’np.array’ with those data. :param input_entity: the Grid2D object to convert. :param normalize: if True, the data will be normalized between 0 and 255. :param keys: the list of the data to extract. :return data: the data extracted from the object.

static data_to_pil_format(input_entity: Grid2D, data: np.ndarray, normalize: bool = True) np.ndarray[source]

Convert a numpy array with a format compatible with PIL.Image object. :param input_entity: the Grid2D object to convert. :param data: the data to convert. :param normalize: if True, the data will be normalized between 0 and 255. :return: the data formatted with the right shape, between 0 and 255, as uint8.

static grid_to_tag(input_entity: Grid2D) dict[source]

Compute the tag dictionary of the :obj:’geoh5py.objects.geo_image.Grid2D’ as required by the :obj:’geoh5py.objects.geo_image.GeoImage’ object. :param input_entity: the Grid2D object to convert. :return tag: the tag dictionary.

static key_to_data(input_entity: Grid2D, key: str | int | UUID | Data) np.ndarray[source]

Extract the data from the entity in :obj:’np.array’ format; The data can be of type: ‘:obj:str’, ‘:obj:int’, ‘:obj:UUID’, or ‘:obj:Data’. :param input_entity: the Grid2D object to convert. :param key: the key of the data to extract. :return: an np. array containing the data.

static to_geoimage(input_entity: Grid2D, keys: list | str | int | UUID | Data, mode: str | None = None, normalize: bool = True, **geoimage_kwargs) GeoImage[source]

Convert the object to a :obj:’GeoImage’ object. :param input_entity: the Grid2D object to convert. :param keys: the data to extract. :param mode: the mode of the image to create. :param normalize: if True, the data will be normalized between 0 and 255. :param geoimage_kwargs: the kwargs to pass to the :obj:’GeoImage’ object.

Module contents