duckdb / duckdb/duckdb-spatial
ST_Intersection_Agg not returning intersects
- Dominant language
- C
- Stars
- 708
- Forks
- 96
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 5
Description
When testing a function, I ran into the situation where ST_Intersection_Agg returns "POLYGON EMPTY". When I view the data in e.g. QGIS, there is clearly an overlap.
Full code:
```python
import duckdb
DB = duckdb.connect()
DB.install_extension("spatial")
DB.load_extension("spatial")
def main() -> None:
# Prepare some test data
"""Creates and prints a Polars DataFrame with ID and WKT geometry."""
DB.execute("""
CREATE TABLE geometries AS
SELECT * FROM ST_Read('data/test_overlap.gml')
""")
DB.sql("SELECT * FROM geometries").show()
# Test for intersections
intersections = DB.execute("""
SELECT
ST_AsText(ST_Intersection_Agg(geometryProperty)) AS overlap
FROM geometries
WHERE geometryProperty IS NOT NULL
""").fetchall()
if intersections[0][0] == "POLYGON EMPTY":
print("No intersections found")
return
# generate_map(intersections) # do something with the returned overlap here
if __name__ == "__main__":
main()
```
And the GML file i'm reading:
```xml
568455.285329327 6817178.14118306568665.336942971 6817321.76081046
568455.285329327 6817178.14118306568561.576507316 6817278.10550521
568455.285329327 6817247.73659721 568521.71731557 6817278.10550521 568561.576507316 6817204.71397755 568500.206005739 6817178.14118306 568455.285329327 6817247.73659721
1
568551.453537983 6817203.44860639568665.336942971 6817316.06664021
568551.453537983 6817286.33041779 568624.212380059 6817316.06664021 568665.336942971 6817238.87899905 568601.435699061 6817203.44860639 568551.453537983 6817286.33041779
2
568490.083036407 6817238.87899905568555.249651483 6817321.76081046
568490.083036407 6817314.16858346 568504.634804822 6817238.87899905 568555.249651483 6817244.5731693 568528.676856986 6817321.76081046 568490.083036407 6817314.16858346
3
```
Dependencies:
```
requires-python = ">=3.14"
dependencies = [
"duckdb>=1.4.2",
"folium>=0.20.0",
"pyarrow>=22.0.0",
]
```
I tried several data formats (GeoJSON, GML, GeoParquet) and projections, but all with the same result. From the description in [the docs](https://github.com/duckdb/duckdb-spatial/blob/v1.4-andium/docs/functions.md#st_intersection_agg), I was expecting a polygon in the shape of the parts of the two features that overlap each other:
```markdown
Computes the intersection of a set of geometries
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.