bigframes.geopandas.GeoSeries.intersection#

GeoSeries.intersection(other: GeoSeries) Series[source]#

Returns a GeoSeries of the intersection of points in each aligned geometry with other.

The operation works on a 1-to-1 row-wise manner.

Examples:

>>> import bigframes as bpd
>>> import bigframes.geopandas
>>> from shapely.geometry import Polygon, LineString, Point

We can check two GeoSeries against each other, row by row.

>>> s1 = bigframes.geopandas.GeoSeries(
...    [
...        Polygon([(0, 0), (2, 2), (0, 2)]),
...        Polygon([(0, 0), (2, 2), (0, 2)]),
...        LineString([(0, 0), (2, 2)]),
...        LineString([(2, 0), (0, 2)]),
...        Point(0, 1),
...    ],
... )
>>> s2 = bigframes.geopandas.GeoSeries(
...    [
...        Polygon([(0, 0), (1, 1), (0, 1)]),
...        LineString([(1, 0), (1, 3)]),
...        LineString([(2, 0), (0, 2)]),
...        Point(1, 1),
...        Point(0, 1),
...    ],
...    index=range(1, 6),
... )
>>> s1
0    POLYGON ((0 0, 2 2, 0 2, 0 0))
1    POLYGON ((0 0, 2 2, 0 2, 0 0))
2             LINESTRING (0 0, 2 2)
3             LINESTRING (2 0, 0 2)
4                       POINT (0 1)
dtype: geometry
>>> s2
1    POLYGON ((0 0, 1 1, 0 1, 0 0))
2             LINESTRING (1 0, 1 3)
3             LINESTRING (2 0, 0 2)
4                       POINT (1 1)
5                       POINT (0 1)
dtype: geometry
>>> s1.intersection(s2)
0                                    None
1    POLYGON ((0 0, 0.99954 1, 0 1, 0 0))
2                       POINT (1 1.00046)
3                   LINESTRING (2 0, 0 2)
4                GEOMETRYCOLLECTION EMPTY
5                                    None
dtype: geometry

We can also do intersection of each geometry and a single shapely geometry:

>>> s1.intersection(bigframes.geopandas.GeoSeries([Polygon([(0, 0), (1, 1), (0, 1)])]))
0    POLYGON ((0 0, 0.99954 1, 0 1, 0 0))
1                                    None
2                                    None
3                                    None
4                                    None
dtype: geometry
Parameters:

other (GeoSeries or geometric object) – The Geoseries (elementwise) or geometric object to find the intersection with.

Returns:

The Geoseries (elementwise) of the intersection of points in each aligned geometry with other.

Return type:

bigframes.geopandas.GeoSeries