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, start_index: int = 0)[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.
start_index (int, 0 or 1, default is 0.) – Start index of the connectivity arrays. Must match the start index of the provided face_node_connectivity and edge_node_connectivity.
- __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, start_index: int = 0)[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)contract_vertices
(indices)Return a simplified network topology by removing all nodes that are not listed in
indices
.copy
()Create a deepcopy.
create_data_array
(data, facet)Create a UgridDataArray from this grid and a 1D array of values.
equals
(other)find_ugrid_dim
(obj)Find the UGRID dimension that is present in the object.
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.
get_connectivity_matrix
(dim, xy_weights)Return the connectivity matrix for the specified UGRID dimension.
get_coordinates
(dim)Return the coordinates for the specified UGRID dimension.
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
(obj, x, y, out_of_bounds, fill_value)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.
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
xmin, ymin, xmax, ymax
Dictionary for grid coordinates.
core_dimension
dimensions
Mapping from UGRID dimension names to lengths.
node dimension, edge dimension.
directed_node_node_connectivity
Directed node to node connectivity.
Returns a numpy array with columns
minx, miny, maxx, maxy
, describing the bounds of every edge in the grid.Centroid (x,y) coordinates of every edge in the UGRID topology
Name of edge dimension
edge_node_coordinates
n_edge, 2, 2
.x-coordinate of every edge in the UGRID topology
y-coordinate of every edge in the UGRID topology
Fill value for UGRID connectivity arrays.
is_geographic
max_connectivity_dimensions
max_connectivity_sizes
Create if needed, and return meshkernel Mesh1d object.
Create if needed, and return meshkernel MeshKernel instance.
Number of edges in the UGRID topology
Number of nodes (vertices) in the UGRID topology
Coordinates (x, y) of the nodes (vertices)
Name of node dimension
Node to edge connectivity.
Node to node connectivity.
Start index for UGRID connectivity arrays.
1