Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions climada/engine/test/test_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions climada/hazard/centroids/centr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions climada/util/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions doc/user-guide/climada_engine_Forecast.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
5 changes: 1 addition & 4 deletions doc/user-guide/climada_entity_Exposures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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."
]
},
{
Expand All @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions doc/user-guide/climada_hazard_Hazard.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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()`."
]
},
{
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ dependencies = [
"contextily",
"dask",
"deprecation",
"fiona",
"gdal",
"geopandas",
"h5py",
Expand Down
1 change: 0 additions & 1 deletion requirements/env_climada.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading