88from pathlib import Path
99from typing import Callable , Dict , NamedTuple , Optional , Union
1010
11- import geopandas
1211import pandas as pd
1312import requests
1413import shapely .errors
@@ -540,6 +539,10 @@ class CsvJobDatabase(JobDatabaseInterface):
540539 :implements: :py:class:`JobDatabaseInterface`
541540 :param path: Path to local CSV file.
542541
542+ .. note::
543+ Support for GeoPandas dataframes depends on the ``geopandas`` package
544+ as :ref:`optional dependency <installation-optional-dependencies>`.
545+
543546 .. versionadded:: 0.31.0
544547 """
545548 def __init__ (self , path : Union [str , Path ]):
@@ -562,6 +565,8 @@ def read(self) -> pd.DataFrame:
562565 and df ["geometry" ].dtype .name != "geometry"
563566 and self ._is_valid_wkt (df ["geometry" ].iloc [0 ])
564567 ):
568+ import geopandas
569+
565570 # `df.to_csv()` in `persist()` has encoded geometries as WKT, so we decode that here.
566571 df = geopandas .GeoDataFrame (df , geometry = geopandas .GeoSeries .from_wkt (df ["geometry" ]))
567572 return df
@@ -578,11 +583,14 @@ class ParquetJobDatabase(JobDatabaseInterface):
578583 :implements: :py:class:`JobDatabaseInterface`
579584 :param path: Path to the Parquet file.
580585
581- .. versionadded:: 0.31.0
582-
583586 .. note::
584587 Support for Parquet files depends on the ``pyarrow`` package
585588 as :ref:`optional dependency <installation-optional-dependencies>`.
589+
590+ Support for GeoPandas dataframes depends on the ``geopandas`` package
591+ as :ref:`optional dependency <installation-optional-dependencies>`.
592+
593+ .. versionadded:: 0.31.0
586594 """
587595 def __init__ (self , path : Union [str , Path ]):
588596 self .path = Path (path )
@@ -601,6 +609,7 @@ def read(self) -> pd.DataFrame:
601609
602610 metadata = pyarrow .parquet .read_metadata (self .path )
603611 if b"geo" in metadata .metadata :
612+ import geopandas
604613 return geopandas .read_parquet (self .path )
605614 else :
606615 return pd .read_parquet (self .path )
0 commit comments