Skip to content

Commit

Permalink
Makes geopandas an optional dependency (#10)
Browse files Browse the repository at this point in the history
* Makes geopandas an optional dependency

* import geopandas when required

Co-authored-by: Eddy <Edward.Comyn-Platt@ecmwf.int>
  • Loading branch information
JamesVarndell and EddyCMWF authored Jan 9, 2023
1 parent 6455963 commit d8da943
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions emohawk/readers/shapefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.


import geopandas as gpd

from . import Reader


Expand All @@ -17,6 +14,9 @@ class ShapefileReader(Reader):
Class for reading and polymorphing ESRI Shapefiles.
"""

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def to_pandas(self, **kwargs):
"""
Return a pandas `dataframe` representation of the data.
Expand All @@ -25,6 +25,8 @@ def to_pandas(self, **kwargs):
-------
pandas.core.frame.DataFrame
"""
import geopandas as gpd

return gpd.read_file(self.source, **kwargs)

def to_json(self, file_name):
Expand Down

0 comments on commit d8da943

Please sign in to comment.