pydeck_grid package#
Layer Classes#
- class GContourLayer(data, datakeys, id=None, opacity=1.0, altitude=0.0, zscale=1.0, global_wrap=False, color='#999999', colormap='turbo', scale=1.0, offset=0.0, vmin=0.0, vmax=1.0, levels=[], linewidth=1, **kwargs)[source]#
Bases:
GridLayerConfigures a deck.gl contour layer for rendering gridded data. This layer only supports rectilinear grids.
- Parameters:
data – xarray.DataSet Data to be visualized
datakeys – dict, Dictionary of data keys to be used for the grid with keys: ‘x’: x coordinate of the grid ‘y’: y coordinate of the grid ‘z’: z coordinate of the grid (optional) ‘c’: scalar value of the grid or ‘u’: u component of the vector field ‘v’: v component of the vector field
id – str, default None Unique name for layer
opacity – float, default 1.0, Opacity of the layer
altitude – float, default 0.0 Base altitude of layer in meters
zscale – float, default 1.0 Multiplier scale for the vertical level of the layer
global_wrap – bool, default False Boolean indicating whether the grid is global and should be wrapped around the globe
color – str, default ‘#999999’ Uniform color of contour lines
colormap – str or matplotlib.cm.ScalarMappable, default ‘turbo’ Colormap to use for the grid as a matplotlib predefined colormap name or a matplotlib ScalarMappable
vmin – float, default 0.0 Minimum value for the colormap (if colormap is a matplotlib colormap name)
vmax – float, default 1.0 Maximum value for the colormap (if colormap is a matplotlib colormap name)
scale – float, default 1.0 Multiplier scale for the values of the grid
offset – float, default 0.0 Offset for the values in the grid
levels – list, default [] List of contour levels to draw
linewidth – float, default 1 Width of the contour lines
- Raises:
GridLayerException – missing or invalid arguments
- class ImageLayer(data, datakeys={'b': 'band', 'c': 'band_data', 'x': 'x', 'y': 'y'}, id=None, opacity=1.0, altitude=0.0, zscale=1.0, global_wrap=False, **kwargs)[source]#
Bases:
GridLayerConfigures a deck.gl image layer for rendering gridded image data. This layer only supports rectilinear grids.
- Parameters:
data – xarray.DataSet Data to be visualized
datakeys – dict, Dictionary of data keys to be used for the grid with keys: ‘x’: x coordinate of the grid ‘y’: y coordinate of the grid ‘b’: band coordinate of the grid ‘z’: z coordinate of the grid (optional) ‘c’: scalar pixel value of the color band or ‘u’: u component of the vector field ‘v’: v component of the vector field
id – str, default None Unique name for layer
opacity – float, default 1.0, Opacity of the layer
altitude – float, default 0.0 Base altitude of layer in meters
zscale – float, default 1.0 Multiplier scale for the vertical level of the layer
global_wrap – bool, default False Boolean indicating whether the grid is global and should be wrapped around the globe
**kwargs – dict Additional keyword arguments for the deck.gl layer
- Raises:
GridLayerException – missing or invalid arguments
- class ParticleLayer(data, datakeys, id=None, opacity=1.0, altitude=0.0, zscale=1.0, global_wrap=False, color='#999999', colormap=None, scale=1.0, offset=0.0, vmin=0.0, vmax=1.0, speed=1.0, npart=1000, size=3, length=12, direction='NAUTICAL_FROM', **kwargs)[source]#
Bases:
GridLayerConfigures a deck.gl particle layer for rendering gridded data as moving particles or meshes.
- Parameters:
data –
- xarray.DataArray
Data to be visualized
- Dictionary of data keys to be used for the grid with keys:
’x’: x coordinate of the grid ‘y’: y coordinate of the grid ‘z’: z coordinate of the grid (optional) and one of: ‘u’: u component of the vector field ‘v’: v component of the vector field or: ‘m’: magnitude of the vector field (optional - defaul 1.0) ‘d’: direction of the vector field
id – str, default None Unique name for layer
opacity – float, default 1.0, Opacity of the layer
altitude – float, default 0.0 Base altitude of layer in meters
zscale – float, default 1.0 Multiplier scale for the vertical level of the layer
global_wrap – bool, default False Boolean indicating whether the grid is global and should be wrapped around the globe
color – str or list, default ‘#999999’ Uniform color for the particles as a hex string or list of RGBA values (0-255)
colormap – str or matplotlib.cm.ScalarMappable, default None If provided, colormap to use for the particles as a matplotlib predefined colormap name or a matplotlib ScalarMappable
vmin – float, default 0.0 Minimum value for the colormap (if colormap is a matplotlib colormap name)
vmax – float, default 1.0 Maximum value for the colormap (if colormap is a matplotlib colormap name)
scale – float, default 1.0 Multiplier scale for the values of the grid
offset – float, default 0.0 Offset for the values in the grid
speed – float, default 1.0 Speed of particles
npart – int, default 1000 Number of particles
size – int, default 3 Size of particles
length – int, default 12 Length of particle tail
direction – string, default: “NAUTICAL_FROM” Type of the vector field direction. One of “NAUTICAL_FROM” (compass degrees), “NAUTICAL_TO” (compass degrees), “CARTESIAN_RADIANS”
**kwargs – dict Additional keyword arguments for the deck.gl layer
- Raises:
GridLayerException - missing on invalid arguments –
- class PartmeshLayer(data, datakeys, id=None, opacity=1.0, altitude=0.0, zscale=1.0, global_wrap=False, color='#999999', colormap=None, scale=1.0, offset=0.0, vmin=0.0, vmax=1.0, speed=1.0, npart=500, animate=True, mesh={'length': 4, 'shape': 'quiver', 'width': 1}, direction='NAUTICAL_FROM', **kwargs)[source]#
Bases:
GridLayerConfigures a deck.gl particle mesh layer for rendering gridded data on a map. This layer only supports rectilinear grids.
- Parameters:
data – xarray.DataSet Data to be visualized
datakeys – dict, Dictionary of data keys to be used for the grid with keys: ‘x’: x coordinate of the grid ‘y’: y coordinate of the grid ‘z’: z coordinate of the grid (optional) and one of: ‘u’: u component of the vector field ‘v’: v component of the vector field or: ‘m’: magnitude of the vector field (optional - defaul 1.0) ‘d’: direction of the vector field
id – str, default None Unique name for layer
opacity – float, default 1.0, Opacity of the layer
altitude – float, default 0.0 Base altitude of layer in meters
zscale – float, default 1.0 Multiplier scale for the vertical level of the layer
global_wrap – bool, default False Boolean indicating whether the grid is global and should be wrapped around the globe
color – str or list, default ‘#999999’ Uniform color for the particles as a hex string or list of RGBA values
colormap – str or matplotlib.cm.ScalarMappable, default None If provided, Colormap to use for the grid as a matplotlib predefined colormap name or a matplotlib ScalarMappable
vmin – float, default 0.0 Minimum value for the colormap (if colormap is a matplotlib colormap name)
vmax – float, default 1.0 Maximum value for the colormap (if colormap is a matplotlib colormap name)
colorres – int, default 256 Number of colors in the colormap
scale – float, default 1.0 Multiplier scale for the values of the grid
offset – float, default 0.0 Offset for the values in the grid
speed – float, default 1.0 Speed of mesh particles
npart – int, default 500 Number of mesh particles
direction – string, default: “NAUTICAL_FROM” Type of the vector field direction. One of “NAUTICAL_FROM” (compass degrees), “NAUTICAL_TO” (compass degrees), “CARTESIAN_RADIANS”
animate – bool, default True Animate meshes
mesh – str or dict, default {“shape”: “quiver”, “width”: 1, “length”: 4} Particle mesh parameters. Possible shapes are ‘cone’,’arrow’,’quiver’. If a string is provided, the mesh will be the specified shape with default lengt and width. If a dictionary is provided, it must contain the key ‘shape’ with one of the possible shapes and optionally the keys ‘width’ and ‘length’ for the width and length of the mesh.
- Raises:
GridLayerException - missing on invalid arguments –
- class PcolorLayer(data, datakeys, id=None, opacity=1.0, altitude=0.0, zscale=1.0, global_wrap=False, colormap='turbo', scale=1.0, offset=0.0, vmin=0.0, vmax=1.0, precision=2, **kwargs)[source]#
Bases:
GridLayerConfigures a deck.gl pcolor layer for rendering gridded data. This layer is pickable with the scalar value available for the tooltip.
- Parameters:
data – xarray.DataSet Data to be visualized
datakeys – dict, Dictionary of data keys to be used for the grid with keys: ‘x’: x coordinate of the grid ‘y’: y coordinate of the grid ‘z’: z coordinate of the grid (optional) ‘c’: scalar value of the grid or ‘u’: u component of the vector field ‘v’: v component of the vector field
id – str, default None Unique name for layer
opacity – float, default 1.0, Opacity of the layer
altitude – float, default 0.0 Base altitude of layer in meters
zscale – float, default 1.0 Multiplier scale for the vertical level of the layer
global_wrap – bool, default False Boolean indicating whether the grid is global and should be wrapped around the globe
colormap – str or matplotlib.cm.ScalarMappable, default ‘turbo’ Colormap to use for the grid as a matplotlib predefined colormap name or a matplotlib ScalarMappable
vmin – float, default 0.0 Minimum value for the colormap (if colormap is a matplotlib colormap name)
vmax – float, default 1.0 Maximum value for the colormap (if colormap is a matplotlib colormap name)
scale – float, default 1.0 Multiplier scale for the values of the grid
offset – float, default 0.0 Offset for the values in the grid
precision – int, default 2 Number of decimal places to round values to for tooltips
**kwargs – dict Additional keyword arguments for the deck.gl layer
- Raises:
GridLayerException - missing on invalid arguments –
- class MaskLayer(mask_url='https://api.mapbox.com/v4/mapbox.country-boundaries-v1/{z}/{x}/{y}.vector.pbf?access_token=', id=None, **kwargs)[source]#
Bases:
LayerConfigures a deck.gl masking layer for creating transparent cutouts. Useful for creating clean shorelines for ocean data.
- Parameters:
mask_url – str, default “https://api.mapbox.com/v4/mapbox.country-boundaries-v1/{z}/{x}/{y}.vector.pbf?access_token={MAPBOX_API_KEY}” URL of the masking tileset. Must be a valid URL to a vector tile tileset following the same conventions as the deck.gl MVTLayer. All of the tileset’s features will be used to mask the data layer.
invert – bool, default False Invert the mask. Useful for masking land instead of water.
- Raises:
GridLayerException – missing or invalid arguments
Grid Layer Base#
- class GridLayer(type, data, datakeys, id=None, colormap=None, vmin=0.0, vmax=1.0, **kwargs)[source]#
Bases:
LayerBase layer for all pydeck grid layers
Configures a deck.gl layer for rendering gridded data on a map. Parameters passed here will be specific to the particular deck.gl grid layer that you are choosing to use.
- colorbar(labels=None, units=None, width=200, height=40, labelcolor='white', style=None)[source]#
Return a colorbar for the layer to use in the pydeck description
- Parameters:
labels – list, optional List of labels to use for the colorbar
units – str, optional Units string to use for the colorbar
width – int, optional Width of the colorbar in pixels
height – int, optional Height of the colorbar in pixels
labelcolor – str, optional Color of the colorbar labels
style – dict, optional Additional style properties to apply to the colorbar