Skip to main content

calculateXYFromBounds()

function calculateXYFromBounds(
bounds,
width,
height,
crs): object;

Converts geographic bounds (lat/lon) to pixel-space indices for slicing Zarr arrays. Supports both EPSG:4326 and EPSG:3857 projections.

Parameters

ParameterTypeDescription
bounds{ east: number; north: number; south: number; west: number; }Geographic bounding box.
bounds.eastnumber-
bounds.northnumber-
bounds.southnumber-
bounds.westnumber-
widthnumberArray width (longitude dimension).
heightnumberArray height (latitude dimension).
crsCRS | nullCoordinate reference system. See CRS.

Returns

object

Start and end pixel indices for X and Y axes.

x

x: [number, number];

y

y: [number, number];