duckdb / duckdb/duckdb-spatial

Imprecise `ST_Intersection` results

Open
#552 15 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
708
Forks
96
Avg merge
1d 21h
Merged PRs (30d)
5

Description

### What happens?

I have two line layers in my GPKG, and when I intersect them using `ST_Intersection`. I get the intersection points slightly off from where they should be.

![Image](https://github.com/user-attachments/assets/9322e3a1-fa41-4c9b-8118-86df8cae9466)

![Image](https://github.com/user-attachments/assets/030c5166-5113-4a3c-9d7e-9e6e4b7fc1d8)

### To Reproduce

Download this file, unzip, and run the following after updating the path

[intersection.zip](https://github.com/user-attachments/files/19933636/intersection.zip)

```sh
INSTALL spatial; LOAD spatial;

CREATE TEMP TABLE intersection (geom GEOMETRY);

WITH xs AS (
SELECT ST_Transform(geom, 'EPSG:2918', 'EPSG:5070') AS geom
FROM st_read('D:\Users\abdul.siddiqui\Downloads\lowercolorado\intersection.gpkg', layer='xs')
),
reaches AS (
SELECT geom
FROM st_read('D:\Users\abdul.siddiqui\Downloads\lowercolorado\intersection.gpkg', layer='reaches')
)
INSERT INTO intersection
SELECT
(ST_Intersection(xs.geom, reaches.geom))
FROM xs, reaches
WHERE ST_Intersects(xs.geom, reaches.geom);

SELECT ST_AsTEXT(geom)
FROM intersection;

SELECT ST_AsTEXT(geom)
FROM st_read('D:\Users\abdul.siddiqui\Downloads\lowercolorado\intersection.gpkg', layer='qgis_intersections');
```

### OS:

Windows x86_64

### DuckDB Version:

1.2.2

### DuckDB Client:

CLI and Python

### Hardware:

_No response_

### Full Name:

Abdul Raheem Siddiqui

### Affiliation:

ERT Inc.

### What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a stable release

### Did you include all relevant data sets for reproducing the issue?

Yes

### Did you include all code required to reproduce the issue?

- [x] Yes, I have

### Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?

- [x] Yes, I have

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.