gregor.aggregate
¶
aggregate_point_to_polygon(points, polygons, aggfunc='sum')
¶
Aggregate point data to polygons.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
GeoDataFrame
|
GeoDataFrame containing data defined on point geometries. |
required |
polygons
|
GeoSeries | GeoDataFrame
|
GeoSeries or GeoDataFrame of polygon geometries. |
required |
aggfunc
|
str
|
Aggregation function, by default "sum". |
'sum'
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
GeoDataFrame containing the original geometries and the aggregated statistics. |
aggregate_raster_to_polygon(raster, polygons, stats='sum')
¶
Aggregate raster data to polygons.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raster
|
str | Path | DataArray
|
Path to the raster file or xarray DataArray. |
required |
polygons
|
GeoSeries | GeoDataFrame
|
GeoSeries or GeoDataFrame with the spatial units. |
required |
stats
|
str
|
Statistics to compute, by default "sum". |
'sum'
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
GeoDataFrame containing the original geometries and the aggregated statistics. |
gregor.disaggregate
¶
logger = logging.getLogger(__name__)
module-attribute
¶
disaggregate_polygon_to_point(data, column, proxy, proxy_column, to_data_crs=False)
¶
Disaggregate polygon data to point data using proxy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
GeoDataFrame
|
Data to be disaggregated. |
required |
column
|
str
|
Column name of the data to be disaggregated. |
required |
proxy
|
GeoSeries
|
Proxy data with point geometries for disaggregation. |
required |
proxy_column
|
str
|
Column name of the proxy data. |
required |
to_data_crs
|
bool
|
Whether to reproject proxy to |
False
|
disaggregate_polygon_to_raster(data, column, proxy, to_data_crs=False)
¶
Disaggregate polygon data to raster data using proxy. Normalization of the proxy happens internally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
GeoDataFrame
|
Data to be disaggregated. |
required |
column
|
str
|
Name of the attribute in |
required |
proxy
|
DataArray
|
Raster whose intensities act as weights. |
required |
to_data_crs
|
bool
|
If True, reprojects the output raster back to |
False
|
Returns:
| Type | Description |
|---|---|
DataArray
|
Disaggregated raster data. |
get_belongs_to_matrix(raster, polygons, nodata=-1)
¶
Get a matrix which indicates which polygon each raster point belongs to.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raster
|
DataArray
|
Raster array to get the matrix for. |
required |
polygons
|
GeoSeries
|
Polygons to compute the matrix for. |
required |
nodata
|
int
|
Value to use as NaN, i.e. for pixels that do not belong to any polygon. |
-1
|
Returns:
| Type | Description |
|---|---|
DataArray
|
Matrix which indicates which polygon each raster point belongs to. |