Skip to content

Commit

Permalink
docs: add a section about the ROI in raster_class
Browse files Browse the repository at this point in the history
  • Loading branch information
vschaffn committed Dec 19, 2024
1 parent 24cf7f1 commit 3e25dec
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions doc/source/raster_class.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,19 @@ rast_crop = rast.crop(crop_geom=(0.3, 0.3, 1, 1))
print(rast_crop.bounds)
```

A crop can also be done during its initialization by passing a Region of Interest (ROI) to the Raster class via the `roi` parameter.
The `roi` can be specified in two formats:
- **Pixel-based ROI:** Defined by the pixel coordinates with the following keys: `left`, `bottom`, `right`, and `top`.
- **Georeferenced ROI:** Defined by geographical coordinates with the following keys: `x_min`, `x_max`, `y_min`, `y_max` and optional `crs` (Coordinate Reference System, defaults to EPSG:4326 if not provided).

```{code-cell} ipython3
# Initialize a raster with a pixel-based ROI
rast_roi = gu.Raster(filename_rast, load_data=True, roi={'left': 100, 'bottom': 200, 'right': 400, 'top': 500})
# Initialize a raster with a georeferenced ROI
rast_roi = gu.Raster(filename_rast, load_data=True, roi={'lat_min': 630175, 'lat_max': 639175, 'lon_min': 4839545, 'lon_max': 4848545, 'crs': 'EPSG:32718'})
```

## Polygonize

Polygonizing a {class}`~geoutils.Raster` is done through the {func}`~geoutils.Raster.polygonize` function, which converts target pixels into a multi-polygon
Expand Down

0 comments on commit 3e25dec

Please sign in to comment.