pylusat.utils module
- pylusat.utils.rasterize_geometry(gdf, cellsize, value_clm=None, value_fill=0)
Transform vector data into a 2-d array. If any (or a part of) geometry presents at a given cell, the cell will be assigned to a value of 1, otherwise 0.
- Parameters:
gdf (geopandas.GeoDataFrame) – Input GeoDataFrame.
cellsize (int or float) – Cell size used to transform the vector data.
value_clm (str, optional) – The name of the column which contains the values for each cell in the output array.
value_fill (int, optional) – Fill value for all areas not covered by the input geometries.
- Returns:
arr (numpy.ndarray) – Output numpy array.
trans (Affine) – An object of the Affine class.
extent (tuple) – a tuple containing
min_x,min_y,max_x,max_yvalues for the bounds of the series as a whole. See GeoSeries.bounds for the bounds of the geometries contained in the series.nodata (int or float) – The no data value used during the rasterization.
- pylusat.utils.cntrd_array(gdf)
Get the coordinates of the centroids in a 2D array.
- Parameters:
gdf (geopandas.GeoDataFrame) – Input GeoDataFrame.
- Returns:
output – An n by 2 2D array where each row contains the coordinates (x and y) of the centroids of each geometry in the input GeoDataFrame.
- Return type:
- pylusat.utils.inv_affine(gdf, cellsize, max_y, min_x)
Convert (x, y) coordinates of the centroids of a GeoDataFrame to (row, column) on a grid.
- Parameters:
- Returns:
An n by 2 2D-array of (row, column) indices for the centroid of each geometry in the input GeoDataFrame.
- Return type:
- pylusat.utils.ahp(r_mtx)
Compute the priority vector of the Analytic Hierarchy Process (AHP).
The computed priority vector can be used as weights in a decision-making process based on multiple criteria. The function also returns the Consistency Ratio (CR) to check whether decisions of pair-wise comparisons are consistent.
- Parameters:
r_mtx (numpy.ndarray) – The reciprocal matrix.
- Returns:
priority_vec (numpy.ndarray) – The priority vector computed by AHP.
cr (float) – Consistency Ratio (1990, Saaty). The rule of thumb is CR <= 0.1.
- pylusat.utils.random_ahp(n=3)
Generate randomized Analytic Hierarchy Process (AHP) weights.
This function generates random weights, i.e., priority vector, using the AHP method (1990, Saaty). The randomly generated weights are ensured to be consistent by evaluating the consistency ratio (CR).
- Parameters:
n (int, optional, default 3) – Number of AHP weights to generate, which must be between 3 and 10.
- Returns:
priority_vec – An array that contains the weights (priority vector of AHP).
- Return type:
- pylusat.utils.weighted_sum(df, col_weights)
Calculate a weighted sum over a list of existing columns.
- Parameters:
df (pandas.DataFrame or GeoDataFrame) – Input DataFrame contains the columns for summation.
col_weights (dict) – Dict of
{column name: float}, where float is the weight for the column specified by the column name.
- Returns:
weighted_sum – An array contains the result of the weighted sum.
- Return type: