xugrid.Ugrid1d#

class xugrid.Ugrid1d(node_x: ndarray, node_y: ndarray, fill_value: int, edge_node_connectivity: ndarray = None, name: str = 'network1d', dataset: Dataset = None, indexes: Dict[str, str] = None, projected: bool = True, crs: Any = None, attrs: Dict[str, str] = None)[source]#

This class stores the topological data of a “1-D unstructured grid”: a collection of connected line elements, such as a river network.

Parameters:
  • node_x (ndarray of floats) –

  • node_y (ndarray of floats) –

  • fill_value (int) –

  • edge_node_connectivity (ndarray of integers) –

  • name (string, optional) – Network name. Defaults to “network1d”.

  • dataset (xr.Dataset, optional) –

  • indexes (Dict[str, str], optional) – When a dataset is provided, a mapping from the UGRID role to the dataset variable name. E.g. {“face_x”: “mesh2d_face_lon”}.

  • projected (bool, optional) – Whether node_x and node_y are longitude and latitude or projected x and y coordinates. Used to write the appropriate standard_name in the coordinate attributes.

  • crs (Any, optional) – Coordinate Reference System of the geometry objects. Can be anything accepted by pyproj.CRS.from_user_input(), such as an authority string (eg “EPSG:4326”) or a WKT string.

  • attrs (Dict[str, str], optional) – UGRID topology attributes. Should not be provided together with dataset: if other names are required, update the dataset instead. A name entry is ignored, as name is given explicitly.

__init__(node_x: ndarray, node_y: ndarray, fill_value: int, edge_node_connectivity: ndarray = None, name: str = 'network1d', dataset: Dataset = None, indexes: Dict[str, str] = None, projected: bool = True, crs: Any = None, attrs: Dict[str, str] = None)[source]#

Methods

__init__(node_x, node_y, fill_value[, ...])

assign_edge_coords(obj)

Assign node coordinates from the grid to the object.

assign_node_coords(obj)

Assign node coordinates from the grid to the object.

clip_box(xmin, ymin, xmax, ymax)

connectivity_matrix(dim, xy_weights)

contract_vertices(indices)

Return a simplified network topology by removing all nodes that are not listed in indices.

copy()

Create a deepcopy.

equals(other)

from_dataset(dataset[, topology])

Extract the 1D UGRID topology information from an xarray Dataset.

from_geodataframe(geodataframe)

Convert geodataframe of linestrings into a UGRID1D topology.

from_meshkernel(mesh[, name, projected, crs])

Create a 1D UGRID topology from a MeshKernel Mesh1d object.

from_shapely(geometry[, crs])

Convert an array of shapely linestrings to UGRID1D topology.

intersect_line(obj, start, stop)

intersect_linestring(obj, linestring)

isel([indexers, return_index])

Select based on node or edge.

merge_partitions(grids)

Merge grid partitions into a single whole.

plot(**kwargs)

Plot the edges of the mesh.

reindex_like(other, obj[, tolerance])

Conform a DataArray or Dataset to match the topology of another Ugrid1D topology.

rename(name[, return_name_dict])

Create a new grid with all variables named according to the default naming conventions.

sel(obj, x, y)

Select a selection of edges, based on edge centroids.

sel_points(x, y)

set_crs([crs, epsg, allow_override])

Set the Coordinate Reference System (CRS) of a UGRID topology.

set_node_coords(node_x, node_y, obj[, projected])

Given names of x and y coordinates of the nodes of an object, set them as the coordinates in the grid.

to_crs([crs, epsg])

Transform geometries to a new coordinate reference system.

to_dataset([other, optional_attributes])

to_nonperiodic(xmax, obj)

to_periodic(obj)

to_pygeos(dim)

to_shapely(dim)

Convert UGRID topology to shapely objects.

topological_sort_by_dfs()

Return an array of vertices in topological order.

topology_subset(edge_index[, return_index])

Create a new UGRID1D topology for a subset of this topology.

Attributes

attrs

bounds

xmin, ymin, xmax, ymax

core_dimension

dimensions

directed_node_node_connectivity

Directed node to node connectivity.

edge_bounds

Returns a numpy array with columns minx, miny, maxx, maxy, describing the bounds of every edge in the grid.

edge_coordinates

Centroid (x,y) coordinates of every edge in the UGRID topology

edge_dimension

Name of edge dimension

edge_node_coordinates

n_edge, 2, 2.

edge_x

x-coordinate of every edge in the UGRID topology

edge_y

y-coordinate of every edge in the UGRID topology

is_geographic

max_connectivity_dimensions

max_connectivity_sizes

mesh

Create if needed, and return meshkernel Mesh1d object.

meshkernel

Create if needed, and return meshkernel MeshKernel instance.

n_edge

Number of edges in the UGRID topology

n_node

Number of nodes (vertices) in the UGRID topology

node_coordinates

Coordinates (x, y) of the nodes (vertices)

node_dimension

Name of node dimension

node_edge_connectivity

Node to edge connectivity.

node_node_connectivity

Node to node connectivity.

sizes

topology_dimension

1