equi7grid.core#

Core module defining the Equi7Grid classes.

Module Contents#

Classes#

Equi7Tile

Defines a tile in the Equi7Grid.

Equi7TilingSystem

Defines a tiling system for each Equi7Grid continent.

Equi7Grid

Defines Equi7Grid with all sub-grid.

Functions#

get_user_equi7grid

Get user-defined Equi7Grid definition.

get_standard_equi7grid

Get standard Equi7Grid definition.

get_equi7grid_from_grid_def

Get Equi7Grid from a grid definition.

get_equi7grid_from_file

Get Equi7Grid from an exported file.

allowed_samplings

Compute samplings which fit into the given tile size.

API#

class equi7grid.core.Equi7Tile#

Bases: pytileproj.RasterTile[typing.Any]

Defines a tile in the Equi7Grid.

class equi7grid.core.Equi7TilingSystem(/, **data: Any)#

Bases: pytileproj.RegularProjTilingSystem

Defines a tiling system for each Equi7Grid continent.

Initialization

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

get_tile_from_name(ftilename: str) equi7grid.core.Equi7Tile#

Get Equi7 tile from a full tilename.

Parameters:

ftilename (str) – Full Equi7 tile name.

Returns:

Equi7 tile corresponding to the given tile name.

Return type:

Equi7Tile

get_tiles_in_geog_bbox(bbox: tuple[float, float, float, float], tiling_id: int | str, *, cover_land: bool = False) equi7grid.core.Equi7TileGenerator#

Get all Equi7 tiles intersecting with the geographic bounding box.

Parameters:
  • bbox (tuple[float, float, float, float]) – Bounding box (x_min, y_min, x_max, y_max) for selecting tiles.

  • tiling_id (int | str) – Tiling level or name. Defaults to the first tiling level.

  • cover_land (bool, optional) – True if only tiles which cover land should be returned. Defaults to false.

Returns:

Yields Equi7 tile after tile, which intersects with the given bounding box.

Return type:

Equi7TileGenerator

get_tiles_in_geom(proj_geom: pytileproj.ProjGeom, tiling_id: int | str, *, cover_land: bool = False) equi7grid.core.Equi7TileGenerator#

Get all Equi7 tiles intersecting with the geographic bounding box.

Parameters:
  • proj_geom (ProjGeom) – Projected geometry representing the region of interest.

  • tiling_id (int | str) – Tiling level or name. Defaults to the first tiling level.

  • cover_land (bool, optional) – True if only tiles which cover land should be returned. Defaults to false.

Returns:

Yields Equi7 tile after tile, which intersects with the given bounding box.

Return type:

Equi7TileGenerator

calc_length_distortion(x: float | numpy.ndarray, y: float | numpy.ndarray) float | numpy.ndarray#

Compute local maximum length distortion k.

k equals the local areal distortion (as always h=1 for the Azimuthal Equidistant projection). Uses planar coordinates thus being much faster, than β€˜calc_length_distortion_on_ellipsoid’.

Parameters:
  • x (float | np.ndarray) – World system coordinates in X direction.

  • y (float | np.ndarray) – World system coordinates in Y direction.

Returns:

k – Local max length distortion = local areal distortion.

Return type:

float | np.ndarray

get_children_from_name(tilename: str) equi7grid.core.Equi7TileGenerator#

Get all child tiles (next higher tiling level).

Parameters:

tilename (str) – Tilename.

Returns:

Yields all tile children as Equi7 tiles.

Return type:

Equi7TileGenerator

get_parent_from_name(tilename: str) equi7grid.core.Equi7Tile#

Get parent tile (next lower tiling level).

Parameters:

tilename (str) – Tilename.

Returns:

Parent Equi7 tile.

Return type:

Equi7Tile

class equi7grid.core.Equi7Grid#

Bases: pytileproj.RegularGrid[equi7grid._types.T_co]

Defines Equi7Grid with all sub-grid.

calc_length_distortion_on_ellipsoid(lon: float, lat: float) float#

Compute local maximum length distortion k on the ellipsoid.

k equals the local areal distortion (as always h=1 for the Azimuthal Equidistant projection)

Parameters:
  • lon (float) – Longitude.

  • lat (float) – Latitude.

Returns:

k – Local max length distortion = local areal distortion.

Return type:

float

get_tiles_in_geog_bbox(bbox: tuple[float, float, float, float], tiling_id: int | str, *, cover_land: bool = False) equi7grid.core.Equi7TileGenerator#

Get all Equi7 tiles intersecting with the geographic bounding box.

Parameters:
  • bbox (tuple[float, float, float, float]) – Bounding box (x_min, y_min, x_max, y_max) for selecting tiles.

  • tiling_id (int | str) – Tiling level or name. Defaults to the first tiling level.

  • cover_land (bool, optional) – True if only tiles which cover land should be returned. Defaults to false.

Returns:

Yields Equi7 tile after tile, which intersects with the given bounding box.

Return type:

Equi7TileGenerator

get_tiles_in_geom(proj_geom: pytileproj.ProjGeom, tiling_id: int | str, *, cover_land: bool = False) equi7grid.core.Equi7TileGenerator#

Get all Equi7 tiles intersecting with the geographic bounding box.

Parameters:
  • proj_geom (ProjGeom) – Projected geometry representing the region of interest.

  • tiling_id (int | str) – Tiling level or name. Defaults to the first tiling level.

  • cover_land (bool, optional) – True if only tiles which cover land should be returned. Defaults to false.

Returns:

Yields Equi7 tile after tile, which intersects with the given bounding box.

Return type:

Equi7TileGenerator

get_tile_from_name(ftilename: str) equi7grid.core.Equi7Tile#

Get Equi7 tile from a full tilename.

Parameters:

ftilename (str) – Full Equi7 tile name.

Returns:

Equi7 tile corresponding to the given tile name.

Return type:

Equi7Tile

equi7grid.core.get_user_equi7grid(sampling: pytileproj._types.SamplingFloatOrMap, tiling_defs: collections.abc.Mapping[int, pytileproj.RegularTilingDefinition], *, buffered: bool = False, continent_order: list[str] | None = None) equi7grid.core.Equi7Grid#

Get user-defined Equi7Grid definition.

Parameters:
  • sampling (float | int | Dict[int | str, float | int]) – Grid sampling/pixel size specified as a single value or a dictionary with tiling IDs as keys and samplings as values.

  • tiling_defs (Dict[int, RegularTilingDefinition]) – Tiling definition (stores name/tiling level and tile size).

  • buffered (bool, optional) – If this flag is set to true, then the buffered projection zone will be used (defaults to false).

  • continent_order (list[str] | None, optional) – Defines the usage and order of the continents.

Returns:

Equi7Grid instance.

Return type:

Equi7Grid

equi7grid.core.get_standard_equi7grid(sampling: pytileproj._types.SamplingFloatOrMap, *, buffered: bool = False, continent_order: list[str] | None = None) equi7grid.core.Equi7Grid#

Get standard Equi7Grid definition.

Parameters:
  • sampling (float | int | Dict[int | str, float | int]) – Grid sampling/pixel size specified as a single value or a dictionary with tiling IDs as keys and samplings as values.

  • buffered (bool, optional) – If this flag is set to true, then the buffered projection zone will be used (defaults to false).

  • continent_order (list[str] | None, optional) – Defines the usage and order of the continents.

Returns:

Equi7Grid instance.

Return type:

Equi7Grid

equi7grid.core.get_equi7grid_from_grid_def(json_path: pathlib.Path, sampling: pytileproj._types.SamplingFloatOrMap, *, continent_order: list[str] | None = None) equi7grid.core.Equi7Grid#

Get Equi7Grid from a grid definition.

Parameters:
  • json_path (Path) – Path to JSON file storing grid definition.

  • sampling (float | int | Dict[int | str, float | int]) – Grid sampling/pixel size specified as a single value or a dictionary with tiling IDs as keys and samplings as values.

  • continent_order (list[str] | None, optional) – Defines the usage and order of the continents.

Returns:

Equi7Grid instance.

Return type:

Equi7Grid

equi7grid.core.get_equi7grid_from_file(json_path: pathlib.Path) equi7grid.core.Equi7Grid#

Get Equi7Grid from an exported file.

Parameters:

json_path (Path) – Path to JSON file storing grid definition.

Returns:

Equi7Grid instance.

Return type:

Equi7Grid

equi7grid.core.allowed_samplings(tile_size: float) list[float]#

Compute samplings which fit into the given tile size.

Parameters:

tile_size (float) – Tile size.

Returns:

Divisors/samplings of the given tile size.

Return type:

list[float]