in data/geospatial/geospatial-gen.py [0:0]
def write_geospatial_with_nan():
geometries_wkt = [
"POINT ZM (10 20 30 40)",
"POINT ZM (50 60 70 80)",
"LINESTRING ZM (90 100 110 120, nan nan nan nan, 130 140 150 160)",
]
schema = pa.schema({"group": pa.utf8(), "wkt": pa.utf8(), "geometry": ga.wkb()})
with parquet.ParquetWriter(
HERE / "geospatial-with-nan.parquet",
schema,
store_schema=False,
compression="none",
) as writer:
geometries = shapely.from_wkt(geometries_wkt)
wkbs = shapely.to_wkb(geometries, flavor="iso")
wkb_array = ga.wkb().wrap_array(pa.array(wkbs, pa.binary()))
batch = pa.record_batch(
{
"group": ["with-nan"] * len(geometries_wkt),
"wkt": geometries_wkt,
"geometry": wkb_array,
}
)
writer.write_batch(batch)