within#
- GeosSeriesAccessor.within(other=None, manner=None, **kwargs)#
Returns True if geometry A is completely inside geometry B.
Applies
shapely.predicates.within
to(self, other)
and returns the result. If noother
data is given, the function gets applied to all possible combinations of theself
data, by expanding the array.- Parameters:
other (pandas.Series or numpy.ndarray or shapely.Geometry, optional) – Second argument to
within
; Default self.manner ('keep' or 'align' or 'expand', optional) – How to apply the
within
to the data; Default None .kwargs – Keyword arguments passed to
within
.
- Returns:
Series with the result of the function applied to self and other, with the same index as self. numpy.ndarray: 2-Dimensional array with the results of the function applied to each combination of geometries between self and other.
- Return type:
- Raises:
ValueError –
other
argument is not a geos Series or shapely NumPy Array
Note
The
manner
argument dictates how the data gets transformed before applyingwithin
:- keep:
Keep the original data as is and simply run the function. This returns a Series where the index is the same as the
self
data.
- align:
Align both Series according to their index, before running the function (we align the data according the
self
data). This returns a Series where the index is the same as theself
data.
- expand:
Expand the data with a new index, before running the function. This means that the result will be an array of dimensions
<len(a), len(b)>
containing the result of all possible combinations of geometries.
Of course, not every method is applicable for each type of
other
input. Here are the allowed manners for each type of input, as well as the default value:Series: keep, align, expand (default: align)
1D ndarray: keep, expand (default: keep)
nD ndarray: keep (default: keep)
Geometry: keep (default: keep)
None (aka. use self): expand (default: expand)