diff --git a/climada/engine/test/test_forecast.py b/climada/engine/test/test_forecast.py index 8e80cb4fe..8c04d83fe 100644 --- a/climada/engine/test/test_forecast.py +++ b/climada/engine/test/test_forecast.py @@ -23,7 +23,6 @@ import unittest from pathlib import Path -import fiona import geopandas as gpd import matplotlib.pyplot as plt import numpy as np @@ -148,11 +147,8 @@ def test_Forecast_plot(self): resolution="10m", category="cultural", name="admin_1_states_provinces" ) if not cantons_file.exists(): - with fiona.open(adm1_shape_file, "r") as source: - with fiona.open(cantons_file, "w", **source.meta) as sink: - for f in source: - if f["properties"]["adm0_a3"] == "CHE": - sink.write(f) + cantons = gpd.read_file(adm1_shape_file, where="adm0_a3 = 'CHE'") + cantons.to_file(cantons_file) ## test plotting functions # should save plot without failing forecast.plot_imp_map( diff --git a/climada/hazard/centroids/centr.py b/climada/hazard/centroids/centr.py index 6ffe66d16..8cd89005d 100644 --- a/climada/hazard/centroids/centr.py +++ b/climada/hazard/centroids/centr.py @@ -811,12 +811,12 @@ def from_meta(cls, meta): @classmethod def from_vector_file(cls, file_name, dst_crs=None): - """Create Centroids object from vector file (any format supported by fiona). + """Create Centroids object from a vector file supported by GeoPandas. Parameters ---------- file_name : str - vector file with format supported by fiona and 'geometry' field. + vector file in a format supported by GeoPandas, with a 'geometry' field. dst_crs : crs, optional reproject to given crs If no crs is given in the file, simply sets the crs. diff --git a/climada/util/coordinates.py b/climada/util/coordinates.py index 1b08af727..3b56f4265 100644 --- a/climada/util/coordinates.py +++ b/climada/util/coordinates.py @@ -2903,12 +2903,12 @@ def refine_raster_data(data, transform, res, method="linear", fill_value=0): def read_vector(file_name, field_name, dst_crs=None): - """Read vector file format supported by fiona. + """Read a vector file in a format supported by GeoPandas. Parameters ---------- file_name : str - vector file with format supported by fiona and 'geometry' field. + vector file in a format supported by GeoPandas, with a 'geometry' field. field_name : list(str) list of names of the columns with values. dst_crs : crs, optional diff --git a/doc/user-guide/climada_engine_Forecast.ipynb b/doc/user-guide/climada_engine_Forecast.ipynb index c0a1dd90b..74ab3037d 100644 --- a/doc/user-guide/climada_engine_Forecast.ipynb +++ b/doc/user-guide/climada_engine_Forecast.ipynb @@ -202,7 +202,7 @@ } ], "source": [ - "import fiona\n", + "import geopandas as gpd\n", "from cartopy.io import shapereader\n", "from climada.util.config import CONFIG\n", "\n", @@ -213,12 +213,8 @@ " resolution=\"10m\", category=\"cultural\", name=\"admin_1_states_provinces\"\n", ")\n", "if not cantons_file.exists():\n", - " with fiona.open(adm1_shape_file, \"r\") as source:\n", - " with fiona.open(cantons_file, \"w\", **source.meta) as sink:\n", - "\n", - " for f in source:\n", - " if f[\"properties\"][\"adm0_a3\"] == \"CHE\":\n", - " sink.write(f)\n", + " cantons = gpd.read_file(adm1_shape_file, where=\"adm0_a3 = 'CHE'\")\n", + " cantons.to_file(cantons_file)\n", "CH_WS_forecast.plot_warn_map(\n", " str(cantons_file),\n", " decision_level=\"polygon\",\n", diff --git a/doc/user-guide/climada_entity_Exposures.ipynb b/doc/user-guide/climada_entity_Exposures.ipynb index ddbe1015b..15b119aa6 100644 --- a/doc/user-guide/climada_entity_Exposures.ipynb +++ b/doc/user-guide/climada_entity_Exposures.ipynb @@ -1654,7 +1654,7 @@ "\n", "## Write (Save) Exposures\n", "\n", - "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." + "Exposures can be saved in any format available for `GeoDataFrame` ([geopandas supported file formats](https://geopandas.org/en/stable/docs/user_guide/io.html#supported-drivers-file-formats)) 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." ] }, { @@ -1663,9 +1663,6 @@ "metadata": {}, "outputs": [], "source": [ - "import fiona\n", - "\n", - "fiona.supported_drivers\n", "from climada import CONFIG\n", "\n", "results = CONFIG.local_data.save_dir.dir()\n", diff --git a/doc/user-guide/climada_hazard_Hazard.ipynb b/doc/user-guide/climada_hazard_Hazard.ipynb index f559a53fe..bdd7ddd18 100644 --- a/doc/user-guide/climada_hazard_Hazard.ipynb +++ b/doc/user-guide/climada_hazard_Hazard.ipynb @@ -275,9 +275,8 @@ "## Part 2: Read hazards from other data\n", "\n", "- 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", - "- MATLAB: Hazards generated with CLIMADA's MATLAB version (.mat format) can be read using `from_mat()`.\n", - "- 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", - "- hdf5: Hazards generated with the CLIMADA in Python (.h5 format) can be read using `from_hdf5()`.\n" + "- hdf5: Hazards generated with the CLIMADA in Python (.h5 format) can be read using `from_hdf5()`.\n", + "- xarray datasets: raster-like data (.nc format) can be read using `from_xarray_raster()`." ] }, { diff --git a/pyproject.toml b/pyproject.toml index 7721dcf1f..307909678 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,6 @@ dependencies = [ "contextily", "dask", "deprecation", - "fiona", "gdal", "geopandas", "h5py", diff --git a/requirements/env_climada.yml b/requirements/env_climada.yml index d838e7f6e..cfed828db 100644 --- a/requirements/env_climada.yml +++ b/requirements/env_climada.yml @@ -12,7 +12,6 @@ dependencies: - dask>=2026.8 - deprecation>=2.1 - eccodes>=2.47 - - fiona>=1.10 - gdal>=3.12,<3.13 - geopandas>=1.1 - h5py>=3.16