Skip to contents

This function computes the number of opportunities between pairs of locations as defined in Lenormand et al. (2016) . For a given pair of location the number of opportunities between the location of origin and the location of destination is based on the number of opportunities in a circle of radius equal to the distance between origin and destination centered in the origin. The number of opportunities at origin and destination are not included.


extract_opportunities(opportunity, distance, check_names = FALSE)



a numeric vector representing the number of opportunities per location. The value should be positive.


a squared matrix representing the distance between locations.


a boolean indicating if the ID location are used as vector names, matrix rownames and colnames and if they should be checked (see Note).


A squared matrix in which each element represents the number of opportunities between a pair of locations.


opportunity and distance should be based on the same number of locations sorted in the same order. It is recommended to use the location ID as vector names, matrix rownames and matrix colnames and to set check_names = TRUE to verify that everything is in order before running this function (check_names = FALSE by default). Note that the function check_format_names() can be used to control the validity of all the inputs before running the main package's functions.


Lenormand M, Bassolas A, Ramasco JJ (2016). “Systematic comparison of trip distribution laws and models.” Journal of Transport Geography, 51, 158-169.


Maxime Lenormand (



opportunity <- mass[, 1]

sij <- extract_opportunities(
  opportunity = opportunity,
  distance = distance,
  check_names = FALSE