import mikeio
mikeio.Grid2D(x0=12.0, nx=2, dx=0.25, y0=55.0, ny=3, dy=0.25, projection="LONG/LAT")<mikeio.Grid2D>
x: [12, 12.25] (nx=2, dx=0.25)
y: [55, 55.25, 55.5] (ny=3, dy=0.25)
projection: LONG/LAT
2D grid.
Origin in the center of cell in lower-left corner x and y axes are increasing and equidistant
| Name | Type | Description | Default |
|---|---|---|---|
| x | array_like | x coordinates of cell centers | None |
| x0 | float | x coordinate of lower-left corner of first cell | 0.0 |
| dx | float | x cell size | None |
| nx | int | number of cells in x direction | None |
| y | array_like | y coordinates of cell centers | None |
| y0 | float | y coordinate of lower-left corner of first cell | 0.0 |
| dy | float | y cell size | None |
| ny | int | number of cells in y direction | None |
| bbox | tuple | (x0, y0, x1, y1) of bounding box | None |
| projection | str | projection string, by default “NON-UTM” | 'LONG/LAT' |
| origin | tuple | user-defined origin, by default None | None |
| orientation | float | rotation angle in degrees, by default 0.0 | 0.0 |
| is_spectral | bool | if True, the grid is spectral, by default False | False |
| is_vertical | bool | if True, the grid is vertical, by default False | False |
| Name | Description |
|---|---|
| bbox | Bounding box (left, bottom, right, top). |
| dx | X grid spacing. |
| dy | Y grid spacing. |
| is_geo | Are coordinates geographical (LONG/LAT)? |
| is_local_coordinates | Are coordinates relative (NON-UTM)? |
| nx | Number of x grid points. |
| ny | Number of y grid points. |
| orientation | Grid orientation. |
| origin | Coordinates of grid origo (in projection). |
| projection | The projection. |
| projection_string | The projection string. |
| x | Array of x coordinates (element center). |
| xy | N-by-2 array of x- and y-coordinates. |
| y | Array of y coordinates (element center). |
| Name | Description |
|---|---|
| contains | Test if a list of points are inside grid. |
| find_index | Find nearest index (i,j) of point(s). |
| get_node_coordinates | Node coordinates for this grid. |
| get_space_axis | Get geographic space axis indices within the geometry’s dims. |
| isel | Return a new geometry as a subset of Grid2D along the given axis. |
| reduce | Return reduced geometry after spatial aggregation. |
| to_geometryFM | Convert Grid2D to GeometryFM2D. |
| to_mesh | Export grid to mesh file. |
Test if a list of points are inside grid.
| Name | Type | Description | Default |
|---|---|---|---|
| coords | array(float) | xy-coordinate of points given as n-by-2 array | required |
| Name | Type | Description |
|---|---|---|
| bool array | True for points inside, False otherwise |
Find nearest index (i,j) of point(s).
| Name | Type | Description | Default |
|---|---|---|---|
| x | float | x-coordinate of point | None |
| y | float | y-coordinate of point | None |
| coords | array(float) | xy-coordinate of points given as n-by-2 array | None |
| area | array(float) | xy-coordinates of bounding box | None |
| Name | Type | Description |
|---|---|---|
| (array(int), array(int)) | i- and j-index of nearest cell |
Node coordinates for this grid.
| Name | Type | Description |
|---|---|---|
| array(float) | 2d array with x,y-coordinates, length=(nx+1)*(ny+1) |
Get geographic space axis indices within the geometry’s dims.
Returns which of the geometry’s dims represent geographic space dimensions, as opposed to spectral or other non-geographic dimensions.
This is used when axis=“space” or axis=“spatial” is specified in operations like aggregate, mean, etc.
| Name | Type | Description |
|---|---|---|
| tuple[int, …] | Space axis indices (0-indexed within geometry.dims). Returns empty tuple if there are no space dimensions (e.g., point geometries, pure spectral geometries). |
Grid2D with dims=(“y”, “x”) returns (0, 1) - both are space. GeometryFMAreaSpectrum with dims=(“element”, “direction”, “frequency”) returns (0,) - only element is space, direction/frequency are spectral. GeometryFMPointSpectrum with dims=(“frequency”,) returns () - no space.
Return a new geometry as a subset of Grid2D along the given axis.
Return reduced geometry after spatial aggregation.
Convert Grid2D to GeometryFM2D.
| Name | Type | Description | Default |
|---|---|---|---|
| z | float | bathymetry values for each node, by default 0 | None |
| west | int | code value for west boundary | 2 |
| east | int | code value for east boundary | 4 |
| north | int | code value for north boundary | 5 |
| south | int | code value for south boundary | 3 |
Export grid to mesh file.
| Name | Type | Description | Default |
|---|---|---|---|
| outfilename | str | path of new mesh file | required |
| z | float or array(float) | bathymetry values for each node, by default 0 if array: must have length=(nx+1)*(ny+1) | None |