rslearn.train.transforms.terrain¶
terrain ¶
Transforms deriving terrain products from an elevation band.
ElevationToSlopeAspect ¶
Bases: Transform
Derive slope and aspect from a single-band elevation image.
The input must be a single-channel elevation raster in meters. Because the
transform runs after materialization, the image is already in the window's
projection, so the pixel spacing is uniform and must be provided in meters via
pixel_size_m (a RasterImage does not carry projection metadata). Pixels
are assumed to be square, which holds for rslearn windows.
Nodata is assumed to be represented as NaN in the input elevation. NaN pixels produce NaN slope and aspect, and since the gradients read neighboring pixels, each NaN also invalidates the slope and aspect of its four orthogonally adjacent pixels.
Gradients use central differences in the interior and one-sided differences on the image border, so slope and aspect on the outermost pixel ring are less accurate than the interior.
Source code in rslearn/train/transforms/terrain.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
compute ¶
Compute the configured terrain bands from an elevation tensor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elevation
|
Tensor
|
THW tensor of elevations in meters. Rows run north to south, following the standard raster convention. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
a CTHW tensor with one channel per configured band. |
Source code in rslearn/train/transforms/terrain.py
apply_image ¶
apply_image(image: RasterImage) -> RasterImage
Derive terrain bands from the given elevation image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image
|
RasterImage
|
a single-channel CTHW elevation image. |
required |
Returns:
| Type | Description |
|---|---|
RasterImage
|
a CTHW image with one channel per configured band. |
Source code in rslearn/train/transforms/terrain.py
forward ¶
forward(input_dict: dict[str, Any], target_dict: dict[str, Any]) -> tuple[dict[str, Any], dict[str, Any]]
Apply the transform over the inputs and targets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_dict
|
dict[str, Any]
|
the input |
required |
target_dict
|
dict[str, Any]
|
the target |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
(input_dict, target_dict) where output_selector contains the terrain |
dict[str, Any]
|
bands. |