Skip to main content
Returns a Series of dtype('bool') with value True for each aligned geometry that is within other. An object is said to be within other if at least one of its points is located in the interior and no points are located in the exterior of the other. If either object is empty, this operation returns False. This is the inverse of contains in the sense that the expression a.within(b) == b.contains(a) always evaluates to True. Note: Sedona’s behavior may also differ from Geopandas for GeometryCollections and for geometries that are equal. The operation works on a 1-to-1 row-wise manner.

Signature

Parameters

GeoSeries or geometric object
required
The GeoSeries (elementwise) or geometric object to test if each geometry is within.
bool | None (default None)
default:"None"
If True, automatically aligns GeoSeries based on their indices. None defaults to True. If False, the order of elements is preserved.

Returns

Series(bool)
This method works in a row-wise manner. It does not check if an element of one GeoSeries is within any element of the other one.
See also
  • GeoSeries.contains

Examples

We can check if each geometry of GeoSeries is within a single geometry:
We can also check two GeoSeries against each other, row by row. The GeoSeries above have different indices. We can either align both GeoSeries based on index values and compare elements with the same index using align=True or ignore index and compare elements based on their matching order using align=False: