Rasterize vector
rasterize_vector(geodataframe, raster_profile, value_column=None, default_value=1.0, fill_value=0.0, 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 |
raster_profile |
Union[Profile, dict]
|
The raster profile used for output grid properties. Needs to include at least CRS, transform, width and height. |
required |
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
|
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 |
---|---|
ndarray
|
Rasterized vector data.. |
Raises:
Type | Description |
---|---|
EmptyDataFrameException
|
The geodataframe does not contain geometries. |
InvalidColumnException
|
Given value_column is not in the input geodataframe. |
NonMatchingCrsException
|
The input GeoDataFrame and raster profile have mismatching CRS. |
NumericValueSignException
|
Input resolution value is zero or negative, or input buffer_value is negative. |
Source code in eis_toolkit/vector_processing/rasterize_vector.py
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 |
|