Reputation: 20119
I have a geopandas
dataframe A
with the geometry field set to a single Point
(x,y). Then I have a second dataframe B
with the geometry field set to some polygon and some other information. For example:
A
geometry
(1,2)
(3,4)
...
and
B
info polygon
ab <some polygon>
bc <some other polygon>
... ...
How do I add a new column to A
with B
's info
field only if the point in A
is inside the polygon in B
?
I would like to end up with something like
A
geometry info
(1,2) ab
(3,4) ab
(7,9) bc
... ...
Upvotes: 1
Views: 1245
Reputation: 20119
Just in case someone else needs it, and assuming your geometry is well-formed, then you can do:
new_df = gpd.sjoin(A,B,how="inner", op='intersects')
this was enough.
Upvotes: 2