Create constant raster
create_constant_raster(constant_value, template_raster=None, coord_west=None, coord_north=None, coord_east=None, coord_south=None, target_epsg=None, target_pixel_size=None, raster_width=None, raster_height=None, nodata_value=None)
Create a constant raster based on a user-defined value.
Provide 3 methods for raster creation: 1. Set extent and coordinate system based on a template raster. 2. Set extent from origin, based on the western and northern coordinates and the pixel size. 3. Set extent from bounds, based on western, northern, eastern and southern points.
Always provide values for height and width for the last two options, which correspond to the desired number of pixels for rows and columns.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
constant_value |
Number
|
The constant value to use in the raster. |
required |
template_raster |
Optional[DatasetReader]
|
An optional raster to use as a template for the output. |
None
|
coord_west |
Optional[Number]
|
The western coordinate of the output raster in [m]. |
None
|
coord_east |
Optional[Number]
|
The eastern coordinate of the output raster in [m]. |
None
|
coord_south |
Optional[Number]
|
The southern coordinate of the output raster in [m]. |
None
|
coord_north |
Optional[Number]
|
The northern coordinate of the output raster in [m]. |
None
|
target_epsg |
Optional[int]
|
The EPSG code for the output raster. |
None
|
target_pixel_size |
Optional[int]
|
The pixel size of the output raster. |
None
|
raster_width |
Optional[int]
|
The width of the output raster. |
None
|
raster_height |
Optional[int]
|
The height of the output raster. |
None
|
nodata_value |
Optional[Number]
|
The nodata value of the output raster. |
None
|
Returns:
Type | Description |
---|---|
Tuple[ndarray, dict]
|
A tuple containing the output raster as a NumPy array and updated metadata. |
Raises:
Type | Description |
---|---|
InvalidParameterValueException
|
Provide invalid input parameter. |
Source code in eis_toolkit/raster_processing/create_constant_raster.py
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 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|