Skip to content

Commit 2fb26f0

Browse files
committed
Improve vector_to_parquet
1 parent 8974984 commit 2fb26f0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

leafmap/common.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11709,14 +11709,15 @@ def gdb_layer_names(gdb_path: str) -> List[str]:
1170911709
return layer_names
1171011710

1171111711

11712-
def vector_to_parquet(source: str, output: str, overwrite=False, **kwargs) -> None:
11712+
def vector_to_parquet(source: str, output: str, crs=None, overwrite=False, **kwargs) -> None:
1171311713
"""
1171411714
Convert a GeoDataFrame or a file containing vector data to Parquet format.
1171511715
1171611716
Args:
1171711717
source (Union[gpd.GeoDataFrame, str]): The source data to convert. It can be either a GeoDataFrame
1171811718
or a file path to the vector data file.
1171911719
output (str): The file path where the Parquet file will be saved.
11720+
crs (str, optional): The coordinate reference system (CRS) to use for the output file. Defaults to None.
1172011721
overwrite (bool): Whether to overwrite the existing output file. Default is False.
1172111722
**kwargs: Additional keyword arguments to be passed to the `to_parquet` function of GeoDataFrame.
1172211723
@@ -11734,6 +11735,9 @@ def vector_to_parquet(source: str, output: str, overwrite=False, **kwargs) -> No
1173411735
gdf = source
1173511736
else:
1173611737
gdf = gpd.read_file(source)
11738+
11739+
if crs is not None:
11740+
gdf = gdf.to_crs(crs)
1173711741
gdf.to_parquet(output, **kwargs)
1173811742

1173911743

0 commit comments

Comments
 (0)