odc.geo.xr.add_to

odc.geo.xr.add_to(xx, map, *, name=None, fmt='png', max_size=4096, resampling='nearest', transparent_pixel=None, cmap=None, clip=False, vmin=None, vmax=None, robust=None, **kw)[source]

Add image to an interactive map.

If map is not supplied, image data url and bounds are returned instead.

Parameters:
  • xx (Any) – The DataArray to display

  • map (Any) – Map object, folium and ipyleaflet are understood; can also be None which will return an image data url and bounds instead.

  • name (Optional[str]) – The name of the layer as it will appear in folium and ipyleaflet Layer Controls. The default None will use the input array name (e.g. xx.name) if it exists.

  • fmt (str) – Compress image format. Defaults to “png”; also supports “webp”, “jpeg”.

  • max_size (int) – If longest dimension is bigger than this, shrink it down before compression; defaults to 4096.

  • resampling (str) – Custom resampling method to use when reprojecting xx to the map CRS; defaults to “nearest”.

  • transparent_pixel (Optional[Tuple[int, int, int]]) – Replace transparent pixels with this value, needed for “jpeg”.

  • cmap (Optional[Any]) – If supplied array is not RGB use this colormap to turn it into one.

  • clip (bool) – When converting to RGB clip input values to fit cmap.

  • vmin (Optional[float]) – Used with matplotlib colormaps

  • vmax (Optional[float]) – Used with matplotlib colormaps

  • robust (Optional[bool]) – Used with matplotlib colormaps, vmin=2%, vmax=98%

Raises:

ValueError – when map object is not understood

Return type:

Any

Returns:

ImageLayer that was added to a map

Returns:

(url, bounds) when map is None.

See also

colorize(), to_rgba()