---
title: "window_from_bounds"
description: "Convert geographic bounds to an outward-rounded GeoTIFF pixel window clipped to the image."
image: "https://tilebox.com/images/tilebox-docs-social-preview.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://tilebox.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# window_from_bounds

import { Fragment } from "astro/jsx-runtime";
import ApiReference from "@docs/components/ApiReference.astro";
import ParamField from "@docs/components/ParamField.astro";

```python
def window_from_bounds(
    geotiff: GeoTIFF,
    bounds: tuple[float, float, float, float],
    *,
    crs: str | int | CRS | Proj,
    require_fully_contained: bool = False,
) -> Window
```

Convert geographic bounds to an outward-rounded GeoTIFF pixel window clipped to the image.

## Parameters

**geotiff**

type: GeoTIFF

The open async-geotiff image.
**bounds**

type: tuple[float, float, float, float]

Coordinates in `(left, bottom, right, top)` order.
**crs**

type: str | int | CRS | Proj

The coordinate reference system of `bounds`.
**require_fully_contained**

type: bool

Whether to reject bounds that extend beyond the image instead of clipping
them. Defaults to `False`.

## Returns

An async-geotiff `Window` containing every pixel touched by the bounds.

<h2 id="request-example">Usage example</h2>

Query scenes intersecting a region, then read that region from the first scene's red band. Run this example in a notebook or another async context.

```python
from shapely import box
from tilebox.datasets import Client, iter_datapoints
from tilebox.datasets.assets import AssetCollection
from tilebox.storage.aio import Client as StorageClient
from tilebox.storage.geotiff import window_from_bounds

bounds = (16.25, 48.15, 16.35, 48.22)
collection = Client().dataset("open_data.aws_earth.sentinel2").collection("L2A")
data = collection.query(
    temporal_extent=("2026-07-20", "2026-07-28"),
    spatial_extent=box(*bounds),
)
datapoint = next(iter_datapoints(data))
assets = AssetCollection.from_datapoint(datapoint)

storage = StorageClient()
geotiff = await storage.open_geotiff(assets["red"])
window = window_from_bounds(geotiff, bounds, crs="EPSG:4326")
raster = await geotiff.read(window=window)
print(raster.data.shape)
```

The query must return at least one datapoint. Bounds are clipped to the selected image; pass `require_fully_contained=True` to reject partial coverage.

Source: https://tilebox.com/docs/api-reference/python/tilebox.storage.aio/window_from_bounds/index.mdx
