sudapy.raster.ops¶
Raster geoprocessing operations: clip, reproject, resample, mosaic, hillshade, slope.
sudapy.raster.ops ¶
Raster geoprocessing operations.
Functions wrap :mod:rasterio to provide high-level raster processing
capabilities: clip, reproject, resample, mosaic, hillshade, and slope.
clip ¶
clip(src: PathLike, clip_vector: PathLike, out: PathLike, *, crop: bool = True, nodata: float | None = None) -> Path
Clip a raster by vector geometries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
PathLike
|
Input raster path. |
required |
clip_vector
|
PathLike
|
Vector file whose geometries define the clip extent. |
required |
out
|
PathLike
|
Output raster path. |
required |
crop
|
bool
|
Whether to crop the raster extent to the vector bounds. |
True
|
nodata
|
float | None
|
NoData value for masked pixels. Defaults to the source nodata. |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the output raster. |
Source code in src\sudapy\raster\ops.py
reproject_raster ¶
reproject_raster(src: PathLike, out: PathLike, to_epsg: int, *, resampling: Resampling = Resampling.nearest) -> Path
Reproject a raster to a new CRS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
PathLike
|
Input raster path. |
required |
out
|
PathLike
|
Output raster path. |
required |
to_epsg
|
int
|
Target EPSG code. |
required |
resampling
|
Resampling
|
Resampling method. |
nearest
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the output raster. |
Source code in src\sudapy\raster\ops.py
resample ¶
Resample a raster by a scale factor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
PathLike
|
Input raster path. |
required |
out
|
PathLike
|
Output raster path. |
required |
scale_factor
|
float
|
Factor to scale resolution (2.0 = double resolution). |
required |
method
|
str
|
Resampling method name: |
'bilinear'
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the output raster. |
Source code in src\sudapy\raster\ops.py
mosaic ¶
Merge multiple raster tiles from a directory into one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src_dir
|
PathLike
|
Directory containing raster tiles. |
required |
out
|
PathLike
|
Output merged raster path. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to the merged raster. |
Source code in src\sudapy\raster\ops.py
hillshade ¶
Generate a hillshade from a DEM raster.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
PathLike
|
Input DEM raster path (single band, elevation values). |
required |
out
|
PathLike
|
Output hillshade raster path. |
required |
azimuth
|
float
|
Sun azimuth in degrees (default 315 = northwest). |
315.0
|
altitude
|
float
|
Sun altitude in degrees above horizon (default 45). |
45.0
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the hillshade raster. |
Source code in src\sudapy\raster\ops.py
slope ¶
Calculate slope in degrees from a DEM raster.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
PathLike
|
Input DEM raster path (single band). |
required |
out
|
PathLike
|
Output slope raster path (values in degrees). |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to the slope raster. |