From e74af7d61beeaec32761f26251eff6f7be4cafa0 Mon Sep 17 00:00:00 2001 From: Jacob Wasserman Date: Mon, 27 Nov 2023 14:55:49 -0500 Subject: [PATCH] Update generate_example to include geometry_bbox parameter --- examples/example.parquet | Bin 27814 -> 29627 bytes examples/example_metadata.json | 3 +++ scripts/generate_example.py | 15 +++++++++++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/examples/example.parquet b/examples/example.parquet index 481e66b38952aac5ee9e2737bc454da3fc1c2794..1e7bc885ae58391ccca1a666aacc08d8ae447fc4 100644 GIT binary patch delta 2319 zcmcIkeP~-%6u)_0W60W3=3aP_I<`7vux0sJYR$Be`(FByWa*N(G%v~iki0ZWv*u&k zHfa=zj#0`cNC}7zVIU$hiYOI9RD1~P1R4EfPUoD8x+&u3P#Fk*-E&`(*1aJ3M=yEz z-E;0azjJ=)oV=GV>fZWZ_v#1H8XIE81FVrn+Yz!Nq|+@uk@2kUobFt-dOb^P-OiJd z-Abi+=hfdtzw+#jz@Klw6H-{jn%FxAh+7YiWB=>&D{Nmmlz)zO9nIb}r(1>de09 zu3QLvv^{HDaE2xX#MElF%wG9U!>s!6o}K!Zv8;Rp%(QszqcoXCTGROaef82CZ~C0d z#ajPIJ0HGBiM@AI`T1{`$FBeN)7%BGhx=)MrP zmY@qk9L6{fvH;P%V5x@ndi!m*`-wC%;R9t&APEr(Hkwy}cw*iTvIrXwvU*Pw015N6 zwzAEZ3=P?A038leqcM6%kMu#p!7-}%~;UR6pHDYsX#?y207zM@7R>n9E?IgxL zuV$G7@C^ymY9^e~vMfdIsp1S=<3l0hWRH-ImRz6-3p5@*lKO*Li9CEUG0taXNz5c- z6HtBvSRw6$-m1xf5q0%>n}DP3D*(mhkEWdNOgs|AIPfU3?=O)}B|!U1#sjSCr5R(5 zqR55Oxdg@cPJ*c&a;M#$RHK6ZhFVb?V-sb$C?1sy(fO&yJ*f%BBikgTP9~mEpc5Eg zFW89MJi-s-`e!p;_d-4SioB0+@&`v!gE+j^)p*x4`90Q^UWESRhx}%QLRfVC1BPFW AFaQ7m delta 569 zcmZ8dJ4?e*6u!1lic}{X60ImGPC`u}XoU_ZZ5kg`n?P;U#XdBBM5`8>Di;5M;E+Xd zcNXgA?&J?p2UkJ-1x}uGt0JBxC+B|W^?mpLZQ$m4;Pzo-SUOXg7;2TPyZgmx#6Q`p zg@i#VCb_+d?Yp2PyuJs7!I`jd^%xjoOqvyg&Tdoui1aRYYN7FNx68x`Sk`)Bu|Gq6 zipI%0&ayx6Bm=A9x1FgWZ9#JYG(a=F-i>n^K9>`F_8b8K9)3o}EqP$jQO5_e1g5YF zph7NflE(y==5PU}O_PI51Og9vlp;^_6xppTt*9K->)4dgi5s3ZFsdAGkmtPk5mxE9 zrC6S=$PHWBIHlz{Fbm*-=D~8m41J!W6!_Q26O){F(OzrYihhb{i`E?d(#-pxhofVL zS}hfL7s!-Kq|q(l5Iy6^Tf#X}(ds2dohuepw{-9$*zEH|k{O`=o5Tb8@Z0!NtwDzn vB#HJ%55JqTkw86tE!2;Ckntv!qJ2vWLNe($ThlQ&#@N4?y+j$yfhB(dS)iUF diff --git a/examples/example_metadata.json b/examples/example_metadata.json index ed69b7c..b31f1fd 100644 --- a/examples/example_metadata.json +++ b/examples/example_metadata.json @@ -108,6 +108,9 @@ }, "edges": "planar", "encoding": "WKB", + "geometry_bbox": { + "column": "bbox" + }, "geometry_types": [ "Polygon", "MultiPolygon" diff --git a/scripts/generate_example.py b/scripts/generate_example.py index 27ea618..50bc284 100644 --- a/scripts/generate_example.py +++ b/scripts/generate_example.py @@ -8,6 +8,7 @@ >>> import json, pprint, pyarrow.parquet as pq >>> pprint.pprint(json.loads(pq.read_schema("example.parquet").metadata[b"geo"])) """ +from collections import OrderedDict import json import pathlib @@ -19,6 +20,14 @@ df = geopandas.read_file(geopandas.datasets.get_path("naturalearth_lowres")) df = df.to_crs("ogc:84") + +geometry_bbox = df.bounds.rename( + OrderedDict( + [("minx", "xmin"), ("miny", "ymin"), ("maxx", "xmax"), ("maxy", "ymax")] + ), + axis=1, +) +df["bbox"] = geometry_bbox.to_dict("records") table = pa.Table.from_pandas(df.head().to_wkb()) @@ -39,14 +48,12 @@ def get_version() -> str: "crs": json.loads(df.crs.to_json()), "edges": "planar", "bbox": [round(x, 4) for x in df.total_bounds], + "geometry_bbox": {"column": "bbox"}, }, }, } -schema = ( - table.schema - .with_metadata({"geo": json.dumps(metadata)}) -) +schema = table.schema.with_metadata({"geo": json.dumps(metadata)}) table = table.cast(schema) pq.write_table(table, HERE / "../examples/example.parquet")