Rasterize vector
rasterize_vector(geodataframe, resolution=None, value_column=None, default_value=1.0, fill_value=0.0, base_raster_profile=None, buffer_value=None, merge_strategy='replace')
Transform vector data into raster data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
geodataframe |
GeoDataFrame
|
The vector dataframe to be rasterized. |
required |
resolution |
Optional[float]
|
The resolution i.e. cell size of the output raster. Optional if base_raster_profile is given. |
None
|
value_column |
Optional[str]
|
The column name with values for each geometry. If None, then default_value is used for all geometries. |
None
|
default_value |
float
|
Default value burned into raster cells based on geometries. |
1.0
|
base_raster_profile |
Optional[Union[Profile, dict]]
|
Base raster profile to be used for determining the grid on which vectors are burned in. If None, the geometries and provided resolution value are used to compute grid. |
None
|
fill_value |
float
|
Value used outside the burned/rasterized geometry cells. |
0.0
|
buffer_value |
Optional[float]
|
For adding a buffer around passed geometries before rasterization. |
None
|
merge_strategy |
Literal[replace, add]
|
How to handle overlapping geometries. "add" causes overlapping geometries to add together the values while "replace" does not. Adding them together is the basis for density computations where the density can be calculated by using a default value of 1.0 and the sum in each cell is the count of intersecting geometries. |
'replace'
|
Returns:
Type | Description |
---|---|
Tuple[ndarray, dict]
|
Rasterized vector data and metadata. |
Raises:
Type | Description |
---|---|
EmptyDataFrameException
|
The geodataframe does not contain geometries. |
InvalidColumnException
|
Given value_column is not in the input geodataframe. |
InvalidParameterValueException
|
No resolution or base_raster_profile is given, or base_raster_profile has the wrong type. |
NumericValueSignException
|
Input resolution value is zero or negative, or input buffer_value is negative. |
Source code in eis_toolkit/vector_processing/rasterize_vector.py
16 17 18 19 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 |
|