From 4286972a0f8d072328fb6a295964f63e017f76e5 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Sat, 12 Aug 2023 08:55:38 +1200 Subject: [PATCH] Geopandas pyogrio driver test code Adding class to load files into a geopandas.GeoDataFrame using pyogrio engine. Supports file formats like geoparquet and flatgeobuf. --- h5tests/geopandas_pyogrio_arr_mean.py | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 h5tests/geopandas_pyogrio_arr_mean.py diff --git a/h5tests/geopandas_pyogrio_arr_mean.py b/h5tests/geopandas_pyogrio_arr_mean.py new file mode 100644 index 0000000..e91dbde --- /dev/null +++ b/h5tests/geopandas_pyogrio_arr_mean.py @@ -0,0 +1,33 @@ +import os +import subprocess + +import h5py +import numpy as np +import pandas as pd + +from .h5test import H5Test, timer_decorator + +try: + os.environ["USE_PYGEOS"] = "0" + import geopandas as gpd + import pyogrio +except ImportError: + completed_process = subprocess.run( + ["mamba", "install", "-c", "conda-forge", "pyogrio", "--yes"] + ) + import pyogrio + + +class GeopandasPyogrioArrMean(H5Test): + @timer_decorator + def run(self): + group = "/gt1l/heights" # not used + variable = "h_ph" + geodataframes = [] + for file in self.files: + # file = "s3://nasa-cryo-scratch/h5cloud/flatgeobuf/ATL03_20230211164520_08111812_006_01.fgb" + # print(f"Loading {file} into geopandas via pyogrio") + gdf = gpd.read_file(filename=file, engine="pyogrio") + geodataframes.append(gdf[variable]) + final_geodataframe: gpd.Series = pd.concat(objs=geodataframes, axis="index") + return np.mean(final_geodataframe)