GitHub user michelelaporta created a discussion: Sedona LEFT JOIN using SPATIAL
INDEX
Good morning Folks,
I'm trying to use sedona spatial index but I can't figure out how to obtain the
same results as if I use a **LEFT JOIN**.
Given a polygon I need to determinate if a given set of points are **WITHIN**
the polygon. The test is very simple:
1 point is inside
1 point is outside
are these points WITHIN the polygon ? Using the LEFT JOIN I obtain the correct
results ( I also want points not in polygon):
```
+-------------------+----------------------------------------------------------------------------------------------------------------------+
|point |geometry
|
+-------------------+----------------------------------------------------------------------------------------------------------------------+
|POINT (38.7 13.17) |POLYGON ((38.72 13.14, 38.72 13.21, 38.68 13.21, 38.68
13.14, 38.72 13.14))|
|POINT (38.74 13.05)|NULL
|
+-------------------+----------------------------------------------------------------------------------------------------------------------+
```
If I use the spatial index the results are different ( the outside point is
missing):
```
+------------------+----------------------------------------------------------------------------------------------------------------------+
|point |geometry
|
+------------------+----------------------------------------------------------------------------------------------------------------------+
|POINT (38.7 13.17)|POLYGON ((38.72 13.14, 38.72 13.21, 38.68 13.21, 38.68
13.14, 38.72 13.14))|
+------------------+----------------------------------------------------------------------------------------------------------------------+
```
How to use spatial index to have the **LEFT JOIN** results?
Any suggestions would be appreciated.
Attaching a java maven project to show the case:
[sedona-spatial-indexing.zip](https://github.com/user-attachments/files/23711205/sedona-spatial-indexing.zip)
Thanks in advance
Michele
**P.S. without using index the "LEFT JOIN" is quite slow using a big dataset.**
GitHub link: https://github.com/apache/sedona/discussions/2520
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]