symmetric_difference#

GeosSeriesAccessor.symmetric_difference(other=None, manner=None, **kwargs)#

Returns the geometry that represents the portions of input geometries that do not intersect.

Applies shapely.set_operations.symmetric_difference to (self, other) and returns the result. If no other data is given, the function gets applied to all possible combinations of the self data, by expanding the array.

Parameters:
  • other (pandas.Series or numpy.ndarray or shapely.Geometry, optional) – Second argument to symmetric_difference; Default self.

  • manner ('keep' or 'align' or 'expand', optional) – How to apply the symmetric_difference to the data; Default None .

  • kwargs – Keyword arguments passed to symmetric_difference.

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:

pandas.Series

Raises:

ValueErrorother argument is not a geos Series or shapely NumPy Array

Note

The manner argument dictates how the data gets transformed before applying symmetric_difference:

  • 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 the self 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)