nearest_neighbour_distribution#

nearest_neighbour_distribution(domain, population_A, population_B, include_boundaries=None, exclude_boundaries=None, boundary_exclude_distance=0, ignore_self=True, remain_within_connected_component=False, visualise_output=False, visualise_output_fig_kwargs={})#

Calculate the nearest neighbour distribution for a given population within a domain. The nearest neighbour distribution is the distribution of distances between each object in population A to any object in population B.

Parameters:
domainmuspan Domain object

The domain in which the objects are observed.

population_Aquery-like

The first population of objects or a query to select them.

population_Bquery-like

The second population of objects or a query to select them.

include_boundariesarray-like, query-like, or None, optional

Boundaries to include in the analysis. Defaults to None.

exclude_boundariesarray-like, query-like, or None, optional

Boundaries to exclude from the analysis. Defaults to None.

boundary_exclude_distancefloat, optional

Buffer to exclude objects located within boundary_exclude_distance from the boundaries. Defaults to 0.

ignore_selfbool, optional

If True, then if the same object ID is present in population_A and population_B, do not allow it to measure the distance to itself (0) as the nearest neighbour distance. Defaults to True.

remain_within_connected_componentbool, optional

If True, the nearest neighbour distances are calculated within connected components. Default is False.

visualise_outputbool, optional

If True, plot the NN distribution. Defaults to False.

visualise_output_fig_kwargsdict, optional

Dictionary to pass to figure creation if visualise_output is True.

Returns:
observed_nearest_distancesnumpy.ndarray

An array of the nearest neighbour distances for the specified population within the prescribed boundaries.