add_binary_distance_band_column()
Annotates a dataframe with a weights column containing the other records within the threshold and their weight.
Parameters
DataFrame
required
DataFrame with geometry column
float
required
Distance threshold for considering neighbors
bool
default:"True"
Whether to include neighbors that are 0 distance. If 0 distance neighbors are included and binary is false, values are infinity as per the floating point spec (divide by 0)
bool
default:"False"
Whether to include self in the list of neighbors
Optional[str]
default:"None"
Name of the geometry column
bool
default:"False"
Whether to use a cartesian or spheroidal distance calculation. Default is false
Optional[List[str]]
default:"None"
The attributes to save in the neighbor column. Default is all columns
str
default:"'weights'"
The name of the resulting column. Default is ‘weights’
Returns
The input DataFrame with a weight column added containing neighbors and their weights (always 1) added to each row
add_distance_band_column()
Annotates a dataframe with a weights column containing the other records within the threshold and their weight.
Parameters
DataFrame
required
DataFrame with geometry column
float
required
Distance threshold for considering neighbors
bool
default:"True"
Whether to use binary weights or inverse distance weights for neighbors (dist^alpha)
float
default:"-1.0"
Alpha to use for inverse distance weights ignored when binary is true
bool
default:"False"
Whether to include neighbors that are 0 distance. If 0 distance neighbors are included and binary is false, values are infinity as per the floating point spec (divide by 0)
bool
default:"False"
Whether to include self in the list of neighbors
float
default:"1.0"
The value to use for the self weight
Optional[str]
default:"None"
Name of the geometry column
bool
default:"False"
Whether to use a cartesian or spheroidal distance calculation. Default is false
Optional[List[str]]
default:"None"
The attributes to save in the neighbor column. Default is all columns
str
default:"'weights'"
The name of the resulting column. Default is ‘weights’
Returns
The input DataFrame with a weight column added containing neighbors and their weights added to each row
add_weighted_distance_band_column()
Annotates a dataframe with a weights column containing the other records within the threshold and their weight.
Parameters
DataFrame
required
DataFrame with geometry column
float
required
Distance threshold for considering neighbors
float
required
Alpha to use for inverse distance weights. Computation is dist^alpha. Default is -1.0
bool
default:"True"
Whether to include neighbors that are 0 distance. If 0 distance neighbors are included and binary is false, values are infinity as per the floating point spec (divide by 0)
bool
default:"False"
Whether to include self in the list of neighbors
float
default:"1.0"
The value to use for the self weight. Default is 1.0
Optional[str]
default:"None"
Name of the geometry column
bool
default:"False"
Whether to use a cartesian or spheroidal distance calculation. Default is false
Optional[List[str]]
default:"None"
The attributes to save in the neighbor column. Default is all columns
str
default:"'weights'"
The name of the resulting column. Default is ‘weights’
Returns
The input DataFrame with a weight column added containing neighbors and their weights (dist^alpha) added to each row
Usage Examples
Weight Types
Binary Weights
Binary weights assign a value of 1.0 to all neighbors within the threshold distance and 0.0 to all others. This is the simplest form of spatial weighting and is created usingadd_binary_distance_band_column().
Inverse Distance Weights
Inverse distance weights use the formuladist^alpha where alpha is typically negative (e.g., -1.0 or -2.0). Closer neighbors receive higher weights, and farther neighbors receive lower weights. Use add_weighted_distance_band_column() for this type.
Flexible Distance Band Weights
Theadd_distance_band_column() function provides flexibility to choose between binary or inverse distance weighting based on the binary parameter, making it the most versatile option.
Notes
- All functions require a DataFrame with at least one geometry column
- Rows in the DataFrame must be unique
- If multiple geometry columns exist and none is named ‘geometry’, the column name must be specified
- The
use_spheroidparameter determines whether to use Cartesian (planar) or spheroidal (great circle) distance calculations - Zero distance neighbors can cause infinite weights when using inverse distance weighting (
binary=False) - The
saved_attributesparameter allows you to control which columns are preserved in the neighbor information

