Geo API
Geo Package
This package contains generic geospatial logic and data for the NGED substation forecast project.
Map of Great Britain using H3 resolution 5 hexagons

Purpose
The geo package is designed to decouple generic geospatial operations from dataset-specific ingestion logic (e.g., ECMWF data processing in dynamical_data). This ensures that any package in the workspace can perform spatial transformations, such as mapping latitude/longitude grids to H3 hexagons, without depending on heavy or unrelated packages.
geo.h3
H3-related utilities for geospatial operations.
Classes
Functions:
compute_h3_grid_weights_for_boundary(boundary, nwp_grid_size_degrees, h3_res, child_h3_res=None)
Computes the H3 grid weights for a geospatial boundary.
Attributes:
| Name | Type | Description |
|---|---|---|
boundary |
The geospatial boundary to find H3 cells for. |
|
nwp_grid_size_degrees |
The size of the regular lat/lon grid in degrees. |
|
h3_res |
The H3 resolution to use for the grid. |
|
child_h3_res |
The H3 resolution to use for the underlying points. If None, it defaults to h3_res + 2. |
Generates the spatial mapping between the hexagonal H3 grid and the regular lat/lon NWP grid.
The mapping is calculated by sampling each H3 cell with finer-resolution child cells and
determining which regular grid cell each child falls into. The grid_size parameter is used to
snap high-resolution H3 cells to the nearest regular NWP grid points.
Source code in packages/geo/src/geo/h3.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
compute_h3_grid_weights(nwp_grid_size_degrees, h3_index, child_h3_res=None)
Computes the proportion mapping for H3 grid cells to a regular lat/lng grid.
This function takes a DataFrame containing H3 indices and calculates how many
child H3 cells at a finer resolution (child_res) fall into each cell of a
regular lat/lng grid of size grid_size.
The regular grid is assumed to be perfectly aligned to 0.0 (e.g., 0.0, grid_size,
grid_size * 2).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
h3_index
|
list[int]
|
List of 64-bit H3 discrete spatial indices. |
required |
nwp_grid_size_degrees
|
float
|
The size of the regular NWP lat/lng grid in degrees (e.g., 0.25). |
required |
child_h3_res
|
int | None
|
The H3 resolution to use for the underlying points. Must be strictly greater than the resolution of the input 'h3_index' column. |
None
|
Source code in packages/geo/src/geo/h3.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
geo.great_britain.load
Functions:
load_gb_boundary()
Loads the boundary geometry for Great Britain from a local GeoJSON file.
The boundary is buffered to ensure that coastal substations and nearby islands are included in the resulting H3 grid without spatial distortion.
Source code in packages/geo/src/geo/great_britain/load.py
10 11 12 13 14 15 16 17 18 19 20 | |