geopandas: how do I merge information only if point is inside a polygon?
<p>I have a <code>geopandas</code> dataframe <code>A</code> with the geometry field set to a single <code>Point</code> (x,y). Then I have a second dataframe <code>B</code> with the geometry field set to some polygon and some other information. For example:</p>

<pre><code>A 
geometry 
(1,2)
(3,4) 
...
</code></pre>

<p>and </p>

<pre><code>B
info    polygon
ab      &lt;some polygon&gt;
bc      &lt;some other polygon&gt;
...     ...
</code></pre>

<p>How do I add a new column to <code>A</code> with <code>B</code>'s <code>info</code> field only if the point  in <code>A</code> is inside the polygon in <code>B</code>?</p>

<p>I would like to end up with something like</p>

<pre><code>A
geometry    info
(1,2)       ab
(3,4)       ab
(7,9)       bc
...         ...
</code></pre>

<p>Just in case someone else needs it, and assuming your geometry is well-formed, then you can do:</p>

<p><code>new_df = gpd.sjoin(A,B,how="inner", op='intersects')</code></p>

<p>this was enough.</p>

python pandas shapefile geopandas