duckdb / duckdb/duckdb-spatial
Width and height of retangular polygons
- Dominant language
- C
- Stars
- 708
- Forks
- 96
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 5
Description
```sql
COPY (
SELECT
*,
width:
ST_Distance_Spheroid(
ST_POINT(ST_XMIN(geometry), ST_YMIN(geometry)),
ST_POINT(ST_XMAX(geometry), ST_YMIN(geometry))
) / 1000,
height:
ST_Distance_Spheroid(
ST_POINT(ST_XMIN(geometry), ST_YMIN(geometry)),
ST_POINT(ST_XMIN(geometry), ST_YMAX(geometry))
) / 1000
FROM 'Thu__18_Jun_2026_15_59_31_GMT.parquet'
limit 10
) TO 'width_height.parquet' (
FORMAT 'PARQUET',
CODEC 'ZSTD',
COMPRESSION_LEVEL 22,
ROW_GROUP_SIZE 15000);
```
The width and height calculated above appear to be 1.5-2x what QGIS is measuring.
Is there a better ST_FUNCTION or way to do this?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the SQL query and compare ST_Distance_Spheroid, ST_XMIN, ST_YMIN, ST_XMAX, and ST_YMAX against the measurements shown in QGIS. Check the geometry and measurement assumptions first; done means identifying whether the discrepancy is expected and documenting or validating the appropriate function for matching width and height.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100