1

I have created a circle which I am trying to intersect with a geodataframe as follows:

circle_gdf=gpd.GeoDataFrame(geometry= [circle])


joinCircle = gpd.sjoin(left_df=circle_gdf, right_df=transactions,  how="left", predicate="intersects")

My aim is to find all transactions that intersects with the circle. The result gives me a geodataframe which contains only the geometry of the circle which is:

POLYGON ((33.58429 -7.62047, 33.58426 -7.62053...

I get no right geometries at all. I am sure there is intersection somewhere. Is there another method of intersecting and checking the result?

0

2 Answers 2

1

You need to set a crs when you create the circle df:

circle_gdf=gpd.GeoDataFrame(geometry=[circle], crs=????)
0
1

You are doing a left join (how="left"), so (only) the geometry of the left_df, so the circle, is retained in the output as explained in the documentation of the how parameter here.

If I understand you correctly, you want to know the geometries of the transactions that intersect the circle. So you need to do an inner join (how="inner") with the transactions as left_df and the circle as right_df to get this result:

circle_gdf=gpd.GeoDataFrame(geometry=[circle])

transactions_in_circle = gpd.sjoin(
    left_df=transactions,
    right_df=circle_gdf,
    how="inner",
    predicate="intersects",
)
1
  • i already tried inner join but the output is empty dataframe
    – bravopapa
    Jan 31 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.