Skip to content

Commit bf55bf4

Browse files
jirhikerclaude
andcommitted
Flatten geometry to 2D before writing GeoPackage
Sites with an elevation produce 3D point geometry ([lon, lat, elev]). GeoServer's GeoPackage reader then fails computing bounds: MismatchedDimensionException: Argument "WGS 84" has 3 dimensions, while 2 was expected. Call force_2d() on the GeoDataFrame before to_file(GPKG). Elevation is still carried as an attribute; only the geometry dimensionality changes. The GeoJSON product on GCS is unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent a1df53d commit bf55bf4

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

orchestration/assets/products.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ def _geojson_to_geopackage(geojson_path: Path, layer_name: str, out_dir: Path) -
172172
if gdf.crs is None:
173173
gdf = gdf.set_crs("EPSG:4326")
174174

175+
# Sites with an elevation get 3D point geometry in the GeoJSON. GeoServer's
176+
# GeoPackage reader rejects a 3D CRS ("WGS 84 has 3 dimensions") when
177+
# computing bounds, so flatten to 2D — elevation remains an attribute.
178+
gdf["geometry"] = gdf.geometry.force_2d()
179+
175180
gpkg_path = out_dir / f"{layer_name}.gpkg"
176181
gdf.to_file(gpkg_path, driver="GPKG", layer=layer_name)
177182
return gpkg_path

0 commit comments

Comments
 (0)