I have two Shapely geometries:
- 1 MultiPoint instance named
multipoints
- 1 Polygon instance named
polygon
I can compute their intersection
by: multipoints.intersection(polyon)
which results in all points that fall inside the polygon.
I'd like to compute their 'non intersection' to get the points which doesn't fall inside the polygon but there is no such: multipoints.notintersection(polyon)
method:
I can use the symmetric_difference
as: multipoints.symmetric_difference(polyon)
but this gives a geometry collection with the points I'm searching for + the whole initial polygon (for which I don't care).
I need to have that done in either one line, or a function that can be plugged into a lambda function for applying it all over the rows of a GeoDataFrame
containing MultiPoint
geometry instances in each row.
Notice; I can use the boolean result of an intersects
inside my lambda but it doesn't seem to work when I apply it on a GeoDataFrame
:
gdf['nonintersectingpoints'] = gdf['my_multipoint_column'].apply(
lambda multipoints: multipoints if not multipoints.intersects(polygon) \
else None
)
(result is None
every where).