Grid Topology

No matter what analysis operations you are performing on the data, visualization of the geometric elements of an unstructured grid (i.e. nodes, edges) without any data mapped to them can always be useful for a number of reasons, including but not limited to understanding the mesh topology and diagnosing patterns or issues with or prior to data analysis (e.g. analyzing the mesh of a dynamical core prior to running a simulation).

UXarray provides convenient functionality to visualize these elements of the Grid object. Below we will introduce those functions, but let us do the initial setup first:


This setup handles the package imports and data loading.


import as ccrs
import geoviews.feature as gf
import holoviews as hv
import uxarray as ux

Read in the data

# File paths
file_dir = "../../meshfiles/"

# We use 480km dataset in this example but there is also 120km dataset
# in the file directory that can be further explored
grid_filename = ""
data_filename = ""

# A standalone grid can be opened for immediate visualization
ux_grid = ux.open_grid(file_dir + grid_filename)

# Visualization through a `UxDataset`'s associated grid, `uxds.uxgrid` is also possible.
uxds = ux.open_dataset(file_dir + grid_filename, file_dir + data_filename)


How to plot through Grid, UxDataset, or UxDataArray?

As the above ux_grid and uxds creation suggests, you may either have a UxDataset (or similarly UxDataArray), or a standalone Grid object. Visualization of the geometric elements of an unstructured grid is possible in all of these cases as follows (Through uxgrid accessor when it is a UxDataset or UxDataArray):

We will demonstrate plotting functions using the standalone ux_grid thorughout this notebook.

Plotting Edges

Plotting the edges of an Unstructured Grid gives us an immediate idea of what the actual mesh looks like since connected edges construct the faces of the grid. Because of this, edge visualization is considered as the default method for Grid topology visualization purposes, and the default plotting method uxarray.Grid.plot(), provides an edge plot as follows:

    title="Default Grid Plot Method",


See also ux_grid.plot.mesh() and ux_grid.plot.edges() that would both create the same plot.


Try xlim and ylim args with the above plot to plot a region of interest only, e.g. xlim=(-170, -50), ylim=(10, 80).

Using exclude_antimeridian

The default grid plot() method as well as mesh() and edges() can take in an optional argument called exclude_antimeridian, which generates the visualization with or without correcting polygons that cross at the antimeridian (± 180 longitude):

    title="Mesh - Exclude Antimeridian Polygons",