Skip to content

Commit 8480553

Browse files
committed
Remove use of fiona
1 parent af793bc commit 8480553

File tree

9 files changed

+24
-40
lines changed

9 files changed

+24
-40
lines changed

climada/engine/test/test_forecast.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import unittest
2424
from pathlib import Path
2525

26-
import fiona
2726
import geopandas as gpd
2827
import matplotlib.pyplot as plt
2928
import numpy as np
@@ -147,12 +146,12 @@ def test_Forecast_plot(self):
147146
adm1_shape_file = shapereader.natural_earth(
148147
resolution="10m", category="cultural", name="admin_1_states_provinces"
149148
)
149+
150150
if not cantons_file.exists():
151-
with fiona.open(adm1_shape_file, "r") as source:
152-
with fiona.open(cantons_file, "w", **source.meta) as sink:
153-
for f in source:
154-
if f["properties"]["adm0_a3"] == "CHE":
155-
sink.write(f)
151+
source = gpd.read_file(adm1_shape_file)
152+
cantons_data = source[source["adm0_a3"] == "CHE"]
153+
cantons_data.to_file(cantons_file)
154+
156155
## test plotting functions
157156
# should save plot without failing
158157
forecast.plot_imp_map(

climada/hazard/centroids/centr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,12 +820,12 @@ def from_meta(cls, meta):
820820

821821
@classmethod
822822
def from_vector_file(cls, file_name, dst_crs=None):
823-
"""Create Centroids object from vector file (any format supported by fiona).
823+
"""Create Centroids object from vector file (any format supported by GeoPandas).
824824
825825
Parameters
826826
----------
827827
file_name : str
828-
vector file with format supported by fiona and 'geometry' field.
828+
vector file with format supported by GeoPandas and 'geometry' field.
829829
dst_crs : crs, optional
830830
reproject to given crs
831831
If no crs is given in the file, simply sets the crs.

climada/util/constants.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@
4545

4646
import matplotlib as mpl
4747

48-
# pylint: disable=unused-import
49-
# without importing numpy ahead of fiona the debugger may run into an error
50-
import numpy
51-
from fiona.crs import from_epsg
52-
5348
from .config import CONFIG
5449

5550
SYSTEM_DIR = CONFIG.local_data.system.dir(create=False)
@@ -212,9 +207,6 @@
212207
DEF_CRS = f"EPSG:{DEF_EPSG}"
213208
"""Default coordinate reference system WGS 84, str, for pyproj and rasterio CRS.from_string()"""
214209

215-
DEF_CRS_FIONA = from_epsg(DEF_EPSG)
216-
"""Default coordinate reference system WGS 84, dict, for fiona interface"""
217-
218210
cm_data1 = [
219211
[0.00000000, 0.00000000, 0.00000000],
220212
[0.00032031, 0.00020876, 0.00015576],

climada/util/coordinates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2635,12 +2635,12 @@ def refine_raster_data(data, transform, res, method="linear", fill_value=0):
26352635

26362636

26372637
def read_vector(file_name, field_name, dst_crs=None):
2638-
"""Read vector file format supported by fiona.
2638+
"""Read vector file format supported by GeoPandas.
26392639
26402640
Parameters
26412641
----------
26422642
file_name : str
2643-
vector file with format supported by fiona and 'geometry' field.
2643+
vector file with format supported by GeoPandas and 'geometry' field.
26442644
field_name : list(str)
26452645
list of names of the columns with values.
26462646
dst_crs : crs, optional

doc/guide/Guide_Euler.ipynb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@
106106
"```bash\n",
107107
"pip install \\\n",
108108
" dask[dataframe] \\\n",
109-
" fiona==1.9 \\\n",
110109
" gdal==3.6 \\\n",
111110
" netcdf4==1.6.2 \\\n",
112111
" rasterio==1.4 \\\n",

doc/tutorial/climada_engine_Forecast.ipynb

Lines changed: 11 additions & 14 deletions
Large diffs are not rendered by default.

doc/tutorial/climada_entity_Exposures.ipynb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,18 +1657,15 @@
16571657
"\n",
16581658
"## Write (Save) Exposures\n",
16591659
"\n",
1660-
"Exposures can be saved in any format available for `GeoDataFrame` (see fiona.supported_drivers) and `DataFrame` ([pandas IO tools](https://pandas.pydata.org/pandas-docs/stable/io.html)). Take into account that in many of these formats the metadata (e.g. variables `ref_year` and `value_unit`) will not be saved. Use instead the format hdf5 provided by `Exposures` methods `write_hdf5()` and `from_hdf5()` to handle all the data."
1660+
"Exposures can be saved in any format available for `GeoDataFrame` and `DataFrame` ([pandas IO tools](https://pandas.pydata.org/pandas-docs/stable/io.html)). Take into account that in many of these formats the metadata (e.g. variables `ref_year` and `value_unit`) will not be saved. Use instead the format hdf5 provided by `Exposures` methods `write_hdf5()` and `from_hdf5()` to handle all the data."
16611661
]
16621662
},
16631663
{
16641664
"cell_type": "code",
1665-
"execution_count": 26,
1665+
"execution_count": null,
16661666
"metadata": {},
16671667
"outputs": [],
16681668
"source": [
1669-
"import fiona\n",
1670-
"\n",
1671-
"fiona.supported_drivers\n",
16721669
"from climada import CONFIG\n",
16731670
"\n",
16741671
"results = CONFIG.local_data.save_dir.dir()\n",

doc/tutorial/climada_hazard_Hazard.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@
262262
"\n",
263263
"- excel: Hazards can be read from Excel files following the template in `climada_python/climada/data/system/hazard_template.xlsx` using the `from_excel()` method. \n",
264264
"- MATLAB: Hazards generated with CLIMADA's MATLAB version (.mat format) can be read using `from_mat()`.\n",
265-
"- vector data: Use `Hazard`'s `from_vector`-constructor to read shape data (all formats supported by [fiona](https://fiona.readthedocs.io/en/latest/manual.html)).\n",
265+
"- vector data: Use `Hazard`'s `from_vector`-constructor to read shape data (all formats supported by GeoPandas).\n",
266266
"- hdf5: Hazards generated with the CLIMADA in Python (.h5 format) can be read using `from_hdf5()`.\n"
267267
]
268268
},

requirements/env_climada.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies:
1010
- dask>=2025.2
1111
- eccodes>=2.40
1212
- gdal>=3.10
13-
- geopandas>=0.14,<1.0 # geopandas 1.0 does not depend on fiona anymore, hence fiona would need to be added as dependency
13+
- geopandas>=0.14
1414
- h5py>=3.12
1515
- haversine>=2.9
1616
- matplotlib-base>=3.10

0 commit comments

Comments
 (0)