xee.fit_geometry
- xee.fit_geometry(geometry, *, geometry_crs='EPSG:4326', buffer=0, grid_crs='EPSG:4326', grid_scale=None, grid_scale_digits=None, grid_shape=None)
Derive grid parameters that cover a geometry.
You must specify exactly one of
grid_scale(pixel size) orgrid_shape(pixel count). When a scale is provided the output pixel shape is computed to fully cover the buffered geometry. When a shape is provided the scale is inferred uniformly over the geometry’s bounding box.- Parameters:
geometry (BaseGeometry) – Shapely geometry defining the area of interest (in
geometry_crsunits).geometry_crs (str) – CRS of the input geometry (default WGS84).
buffer (float) – Optional positive distance in CRS units to expand the geometry.
grid_crs (str) – Target CRS for the output grid.
grid_scale (tuple[float, float] | None) – Optional
(x_scale, y_scale)ingrid_crsunits.ymay be negative for north-up orientation.grid_scale_digits (int | None) – If provided with
grid_shapeworkflow, round inferred scales to this number of decimal places.grid_shape (tuple[int, int] | None) – Optional
(width, height)pixel count.
- Returns:
PixelGridParamsdictionary usable withxarray.open_dataset.- Raises:
ValueError – If both or neither of
grid_scale/grid_shapeprovided.TypeError – If
grid_scaleis malformed.
- Return type: