@@ -22,6 +22,16 @@ def _assert_is_pandas_df(x, file_type: str) -> None:
2222 )
2323
2424
25+ def _assert_is_geopandas_df (x ):
26+ # Assume we have already protected against uninstalled geopandas
27+ import geopandas as gpd
28+
29+ if not isinstance (x , gpd .GeoDataFrame ):
30+ raise NotImplementedError (
31+ "Currently only geopandas.GeoDataFrame can be saved to a GeoParquet."
32+ )
33+
34+
2535def load_path (meta , path_to_version ):
2636 # Check that only a single file name was given
2737 fnames = [meta .file ] if isinstance (meta .file , str ) else meta .file
@@ -104,6 +114,17 @@ def load_data(
104114
105115 return pd .read_csv (f )
106116
117+ elif meta .type == "geoparquet" :
118+ try :
119+ import geopandas as gpd
120+ except ModuleNotFoundError :
121+ raise ModuleNotFoundError (
122+ 'The "geopandas" package is required to read "geoparquet" type '
123+ "files."
124+ ) from None
125+
126+ return gpd .read_parquet (f )
127+
107128 elif meta .type == "joblib" :
108129 import joblib
109130
@@ -144,6 +165,8 @@ def save_data(obj, fname, type=None, apply_suffix: bool = True) -> "str | Sequen
144165 if apply_suffix :
145166 if type == "file" :
146167 suffix = "" .join (Path (obj ).suffixes )
168+ elif type == "geoparquet" :
169+ suffix = ".parquet"
147170 else :
148171 suffix = f".{ type } "
149172 else :
@@ -175,6 +198,11 @@ def save_data(obj, fname, type=None, apply_suffix: bool = True) -> "str | Sequen
175198
176199 obj .to_parquet (final_name )
177200
201+ elif type == "geoparquet" :
202+ _assert_is_geopandas_df (obj )
203+
204+ obj .to_parquet (final_name )
205+
178206 elif type == "joblib" :
179207 import joblib
180208
0 commit comments