bordado.inside

Contents

bordado.inside#

bordado.inside(coordinates, region)[source]#

Determine which points fall inside a given region.

Points at the boundaries are counted as being inside the region.

Parameters:
coordinatestuple = (easting, northing, …)

Tuple of arrays with the coordinates of each point. Should be in an order compatible with the order of boundaries in region. Arrays can be Python lists. Arrays can be of any shape but must all have the same shape.

regiontuple = (W, E, S, N, …)

The boundaries of a given region in Cartesian or geographic coordinates. Should have a lower and an upper boundary for each dimension of the coordinate system.

Returns:
are_insidearray of booleans

An array of booleans with the same shape as the input coordinate arrays. Will be True if the respective coordinates fall inside the area, False otherwise.

Examples

>>> east = [1, 2, 3, 4, 5, 6]
>>> north = [10, 11, 12, 13, 14, 15]
>>> region = (2.5, 5.5, 12, 15)
>>> print(inside((east, north), region))
[False False  True  True  True False]
>>> # This also works for 2D-arrays
>>> east = [[1, 2, 3],
...         [1, 2, 3],
...         [1, 2, 3]]
>>> north = [[5, 5, 5],
...          [7, 7, 7],
...          [9, 9, 9]]
>>> region = (0.5, 2.5, 7, 9)
>>> print(inside((east, north), region))
[[False False False]
 [ True  True False]
 [ True  True False]]
>>> # and 3D-arrays or higher dimensions
>>> east = [[[1, 2, 3],
...          [1, 2, 3],
...          [1, 2, 3]],
...         [[1, 2, 3],
...          [1, 2, 3],
...          [1, 2, 3]]]
>>> north = [[[5, 5, 5],
...           [7, 7, 7],
...           [9, 9, 9]],
...          [[5, 5, 5],
...           [7, 7, 7],
...           [9, 9, 9]]]
>>> up = [[[4, 4, 4],
...        [4, 4, 4],
...        [4, 4, 4]],
...       [[6, 6, 6],
...        [6, 6, 6],
...        [6, 6, 6]]]
>>> region = (0.5, 2.5, 7, 9, 4.5, 7)
>>> print(inside((east, north, up), region))
[[[False False False]
  [False False False]
  [False False False]]

 [[False False False]
  [ True  True False]
  [ True  True False]]]