Skip to content

Commit 98c7d9a

Browse files
authored
CLI: 'crs' in geoparquet metadata should be optional. (#411)
GeoParquet spec allows crs to be optional in the metadata. If missing don't pass it through the GeoArrow metadata. Tested with a geoparquet file with a missing crs. Displays it with this fix.
1 parent dfd8c87 commit 98c7d9a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lonboard/_cli.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,14 @@ def read_geoparquet(path: Path):
7070
i for (i, name) in enumerate(table.schema.names) if name == geometry_column_name
7171
][0]
7272

73-
crs_dict = geo_meta["columns"][geometry_column_name]["crs"]
74-
75-
# Parse CRS and create PROJJSON
76-
ext_meta = {"crs": crs_dict}
77-
7873
metadata = {
7974
b"ARROW:extension:name": b"geoarrow.wkb",
80-
b"ARROW:extension:metadata": json.dumps(ext_meta).encode(),
8175
}
76+
crs_dict = geo_meta["columns"][geometry_column_name].get("crs")
77+
if crs_dict:
78+
# Parse CRS and create PROJJSON
79+
ext_meta = {"crs": crs_dict}
80+
metadata[b"ARROW:extension:metadata"] = json.dumps(ext_meta).encode()
8281

8382
new_field = table.schema.field(geometry_column_index).with_metadata(metadata)
8483
new_schema = table.schema.set(geometry_column_index, new_field)

0 commit comments

Comments
 (0)