stackstac.xyztile_of_array#
- 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, andzshould follow the “slippy map” tiling scheme used by OSM/Google (the standard scheme for most web maps).Requires the
mercantilepackage (installed automatically with'stackstac[viz]').Warning
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.)
- Parameters:
arr (
DataArray) – DataArray to extract a map tile from. Must havexandy, and theepsgcoordinate set.x (
int) – X index of the tiley (
int) – Y index of the tilez (
int) – Zoom level of the tileinterpolation (
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.
- Returns:
Reprojected slice of
arrcorresponding to the tile, or None ifarrdidn’t overlap the tile.- Return type:
xarray.DataArray or None