Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with intersects predicate for spatial joins #147

Open
pierrethiriet opened this issue May 27, 2024 · 3 comments
Open

Issue with intersects predicate for spatial joins #147

pierrethiriet opened this issue May 27, 2024 · 3 comments
Labels
bug Something isn't working juliacon To be implemented for JuliaCon

Comments

@pierrethiriet
Copy link

I am currently testing GeometryOps package to move away from R and the sf package for GIS work. I am facing a minor issue (misusage or bug ?) while using the spatial join function.
The following example with GO.within is working as expected :

using FlexiJoins, DataFrames
import GeoInterface as GI
import GeometryOps as GO

pl = GI.Polygon([GI.LinearRing([(0, 0), (1, 0), (1, 1), (0, 0)])])
pu = GI.Polygon([GI.LinearRing([(0, 0), (0, 1), (1, 1), (0, 0)])])
poly_df = DataFrame(geometry = [pl, pu], color = [:red, :blue])
points = tuple.(rand(1000), rand(1000))
points_df = DataFrame(geometry = points)

joined_df_within = FlexiJoins.innerjoin(
 (points_df, poly_df),
    by_pred(:geometry, GO.within, :geometry)
)

But the GO.intersects predicate fails :

joined_df_intersects = FlexiJoins.innerjoin(
 (points_df, poly_df),
    by_pred(:geometry, GO.intersects, :geometry)
)

Giving the following error:

ERROR: MethodError: no method matching 
swap_sides(::typeof(GeometryOps.intersects))

While the predicate is otherwise working as expected

[GO.intersects(g1, g2) for g1 in points_df.geometry for g2 in poly_df.geometry]

The versions used are the following :

Julia 1.10
  [e37f2e79] FlexiJoins v0.1.33       
  [cf35fbd7] GeoInterface v1.3.4      
  [3251bfac] GeometryOps v0.1.5  

Thanks

@asinghvi17
Copy link
Member

asinghvi17 commented May 27, 2024

This looks like we didn't define a method for FlexiJoins. Will take a look.

@asinghvi17
Copy link
Member

I should have a fix for this today or tomorrow. In the meanwhile, you can define the following functions:

FlexiJoins.swap_sides(::typeof(GO.intersects)) = !GO.disjoint
FlexiJoins.swap_sides(::typeof(!(GO.disjoint))) = GO.intersects
FlexiJoins.swap_sides(::typeof(GO.disjoint)) = !GO.intersects
FlexiJoins.swap_sides(::typeof(!(GO.intersects))) = GO.disjoint

@pierrethiriet
Copy link
Author

Thanks a lot.

@asinghvi17 asinghvi17 added bug Something isn't working juliacon To be implemented for JuliaCon labels Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working juliacon To be implemented for JuliaCon
Projects
None yet
Development

No branches or pull requests

2 participants