stackstac.xyztile_of_array(arr, x, y, z, interpolation='linear', tilesize=256)#

Slice an XYZ tile out of a DataArray. Returns None if the tile does not overlap.

x, y, and z should follow the “slippy map” tiling scheme used by OSM/Google (the standard scheme for most web maps).

Requires the mercantile package (installed automatically with 'stackstac[viz]').


This method is very slow on large arrays due to inefficiencies in generating the dask graphs. (The graphs should compute quickly, but generating and optimizing them is very slow.)

  • arr (DataArray) – DataArray to extract a map tile from. Must have x and y, and the epsg coordinate set.

  • x (int) – X index of the tile

  • y (int) – Y index of the tile

  • z (int) – Zoom level of the tile

  • 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.

  • tilesize (int) – The length of the edge of the tile, in pixels.


Reprojected slice of arr corresponding to the tile, or None if arr didn’t overlap the tile.

Return type:

xarray.DataArray or None