stackstac.add_to_map(arr, map, name=None, range=None, cmap=None, checkerboard=True, interpolation='linear')#

Add the DataArray to an ipyleaflet.Map as a new layer or replacing an existing one.

By giving a name, you can change and re-run notebook cells without piling up extraneous layers on your map.

As you pan around the map, the part of the array that’s in view is computed on the fly by dask. This requires using a dask distributed cluster.

  • arr (DataArray) –

    DataArray to visualize. Must have x and y, and optionally band dims, and the epsg coordinate set.

    arr must have 1-3 bands. Single-band data can be colormapped; multi-band data will be displayed as RGB. For 2-band arrays, the first band will be duplicated into the third band’s spot, then shown as RGB.

  • map (Map) – ipyleaflet.Map to show the array on.

  • name (str) –

    Name of the layer. If there’s already a layer with this name on the map, its URL will be updated. Otherwise, a new layer is added.

    If None (default), is used as the name. If a layer with this name already exists, it will be replaced.

  • range (Optional[Tuple[float, float]]) –

    Min and max values in arr which will become black (0) and white (255) in the visualization.

    If None (default), it will automatically use the 2nd/98th percentile values of the entire array (unless it’s a boolean array; then we just use 0-1). For large arrays, this can be very slow and expensive, and slow down tile rendering a lot, so passing an explicit range is usually a good idea.

  • cmap (Union[str, Colormap, None]) –

    Colormap to use for single-band data. Can be a matplotlib colormap name as a string, or a Colormap object for custom colormapping.

    If None (default), the default matplotlib colormap (usually viridis) will automatically be used for 1-band data. Setting a colormap for multi-band data is an error.

  • checkerboard (bool) –

    Whether to show a checkerboard pattern for missing data (default), or leave it fully transparent.

    Note that only NaN is considered a missing value; any custom fill value should be converted to NaN before visualizing.

  • interpolation (Literal[‘linear’, ‘nearest’]) – Interpolation method to use while reprojecting: "linear" or "nearest" (default "linear"). Use "linear" for continuous data, such as imagery, SAR, DEMs, weather data, etc. Use "nearest" for discrete/categorical data, such as classification maps.


The new or existing layer for visualizing this array.

Return type: