duckdb / duckdb/duckdb-spatial
BUG: ST_Makevalid on Invalid Multipolygon: 'IllegalArgumentException: Overlay input is mixed-dimension'
- Dominant language
- C
- Stars
- 708
- Forks
- 96
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 5
Description
Hi, I'm running into an error `'IllegalArgumentException: Overlay input is mixed-dimension' `when calling ST_MakeValid on an invalid Multipolygon geometry.
**Steps to reproduce:**
```
set geometry_always_xy = true;
create or replace table faulty_geom as select
st_geomfromwkb(geom_conus) as geom_conus,
st_transform(st_geomfromwkb(geom_conus) ,'epsg:5070', 'epsg:4326') as geom_wsg84
from read_parquet('~/Downloads/test_geom_conus.parquet');
select
ST_GeometryType(geom_conus),
st_isvalid (geom_conus),
st_isempty (geom_conus),
ST_HasZ (geom_conus),
ST_GeometryType(geom_wsg84),
st_isvalid (geom_wsg84), -- The geom is invalid
st_isempty (geom_wsg84),
ST_HasZ (geom_wsg84),
from
faulty_geom;
select st_makevalid(geom_wsg84) from faulty_geom ; -- this line fails
```
**Possible Workarounds**
- Now in this case using the buffer trick with the following works:
`select st_makevalid(st_buffer(geom_wsg84,0)) from faulty_geom'
- Unnesting the multipolygons into polygons then operating also works
```
with unnested as (
select (st_makevalid (unnest(st_dump (geom_wsg84)).geom)) as geom
from faulty_geom
)
select st_isvalid (ST_Union_Agg (geom))
from unnested
```
But I'd like to understand why `ST_MakeValid` fails in this case, and whether this is a bug that can be fixed. In general i've been dealing with invalid geoms by just calling `ST_MakeValid`
Fyi this is what the geom looks like , i suspect the extremely thin polygons that look like lines may be causing an issue.
**Duckdb Version**
Running duckdb 1.5.2 with spatial version https://github.com/duckdb/duckdb-spatial/commit/dc1996bfd16bd8614fb4ccb5895b3ee0dbd4298e
[test_geom_conus.parquet.zip](https://github.com/user-attachments/files/26978997/test_geom_conus.parquet.zip)
'
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.