Skip to content

Commit 686216e

Browse files
authored
Fix geometry type "2.5D Unknown" is not supported (#229)
1 parent 069fd47 commit 686216e

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### Improvements
66

7-
- Add automatic detection of 2.5D geometries in write_dataframe (#223)
7+
- Add automatic detection of 2.5D geometries in write_dataframe (#223, #229)
88
- Add "driver" property to read_info result (#224)
99

1010
## 0.5.1 (2023-01-26)

pyogrio/geopandas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ def write_dataframe(
362362

363363
if geometry_type is None:
364364
geometry_type = tmp_geometry_type
365-
if has_z:
365+
if has_z and geometry_type != "Unknown":
366366
geometry_type = f"2.5D {geometry_type}"
367367

368368
crs = None

pyogrio/tests/test_geopandas_io.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,14 +891,26 @@ def test_write_geometry_z_types(tmp_path, wkt, geom_types):
891891
),
892892
("Point Z + Point", "2.5D Point", True, ["Point Z (0 0 0)", "Point (0 0)"]),
893893
("Point Z + None", "2.5D Point", False, ["Point Z (0 0 0)", None]),
894+
(
895+
"Point Z + LineString Z",
896+
"Unknown",
897+
False,
898+
["LineString Z (0 0 0, 1 1 0)", "Point Z (0 0 0)"],
899+
),
900+
(
901+
"Point Z + LineString",
902+
"Unknown",
903+
True,
904+
["LineString (0 0, 1 1)", "Point Z (0 0 0)"],
905+
),
894906
],
895907
)
896908
def test_write_geometry_z_types_auto(
897909
tmp_path, ext, test_descr, exp_geometry_type, mixed_dimensions, wkt
898910
):
899911
# Shapefile has some different behaviour that other file types
900912
if ext == ".shp":
901-
if exp_geometry_type == "2.5D GeometryCollection":
913+
if exp_geometry_type in ("2.5D GeometryCollection", "Unknown"):
902914
pytest.skip(f"ext {ext} doesn't support {exp_geometry_type}")
903915
elif exp_geometry_type == "2.5D MultiLineString":
904916
exp_geometry_type = "2.5D LineString"

0 commit comments

Comments
 (0)