Skip to content

Polygon Z (WKB)

vectorWKBPolygonEPSG:4326tinybundled

A closed 5-vertex ring with a Z ramp, stored as raw WKB. Z lives in the geometry-type header, so a reader that parses the type as a plain 16-bit code sees a 2D polygon and reads the elevations as coordinates.

Polygon geometry of polygon_z_wkb, rendered from the case's data
Polygon geometry, rendered from the case's actual geometry. Scale is normalized to the viewport and is not comparable between cases.
Property Value
Case ID polygon_z_wkb
Category vector
Format WKB
Geometry type Polygon
CRS EPSG:4326
Location Copenhagen, Denmark (synthetic) — 12.50°E, 55.70°N → 12.52°E, 55.72°N
Test tier unit
Size class tiny
Storage class bundled
Redistributable yes
Loader geopandas
Status validated

Use this case

import pytest


@pytest.mark.geocase_case("polygon_z_wkb")
def test_polygon_z_wkb(geocase_case) -> None:
    data = geocase_case.load()
    assert data is not None

Use GeoCase in your tests

Install the complete set of vector, raster, and NetCDF dependencies:

pip install "geocase[all]"

View GeoCase on PyPI.

What this case checks

Verify that the third ordinate survives a WKB round trip and is not silently dropped or mistaken for an attribute.

Risk types covered

Expected behavior

Assertion Expected
expect_loadable yes
expect_valid_geometry yes
expected_geometry_types Polygon
required_drivers none — no OGR driver opens this format (use shapely)

Notes

Purpose

Every other vector fixture in this catalog is 2D, so a consumer that silently drops the third dimension passes all of them. This is the raw-WKB half of a two-file pair that closes that gap.

Data

  • Geometry: POLYGON Z ((12.5 55.7 0, 12.52 55.7 12.5, 12.52 55.72 25, 12.5 55.72 12.5, 12.5 55.7 0))
  • Feature count: 1
  • CRS: EPSG:4326

The Z values ramp 0 → 12.5 → 25 → 12.5 → 0. They are distinct and non-monotonic on purpose: a truncated or reordered dimension shows up as wrong values rather than as a plausible ramp.

Where Z lives in WKB, and how it goes missing

WKB encodes dimensionality in the geometry type code itself. A 2D polygon is type 3; a POLYGON Z is type 1003 (or 0x80000003 under the alternative convention — both are in the wild). A parser that masks the code to its low bits, or assumes the ISO convention when the file uses the EWKB one, reads type 3, expects pairs, and consumes the Z values as the next point's X.

That failure is not subtle in its results, but it is completely silent at the point it happens.

Typical checks

  • geom.has_z is True.
  • Every exterior coordinate is a 3-tuple.
  • The Z values match the ramp above.

polygon_z_gpkg carries the same ring through OGR into a GeoPackage — where dimensionality is a per-geometry flag byte rather than part of the type code, and where a driver can quietly write the 2D form. The pair is what makes the transcoding question answerable; one file alone would only prove that shapely round-trips Z.

Not a cross-format family member

These two carry no canonical_source_case_id and no cross_format_canonical tag. They vary a property the transcoding family deliberately holds constant, so diffing them against a 2D canonical would report the fixture's entire purpose as drift. Same choice, for the same reason, as the procedural cases.

Generation

Generated by scripts/generate_vector_fixtures.py — do not hand-edit. WKB is pure Python with no driver in the loop, so --check compares it byte-for-byte.

Required capabilities

  • load
  • geometry-inspection

Files

Browse this case on GitHub

Source and license

  • Source: geocase-curated
  • License: MIT

Tags

dimensionality three-dimensional vector wkb