Skip to content

Commit 51b66fa

Browse files
Remove geopandas.datasets (#1052)
Use cartopy.io.shapereader for loading natural earth data instead of geopandas
1 parent a5a3fef commit 51b66fa

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

climada/hazard/test/test_tc_tracks.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
import numpy as np
2828
import pandas as pd
2929
import xarray as xr
30-
from shapely.geometry import LineString, MultiLineString, Point
30+
from cartopy.io import shapereader
31+
from shapely.geometry import LineString, MultiLineString
3132

3233
import climada.hazard.tc_tracks as tc
3334
import climada.util.coordinates as u_coord
@@ -1278,8 +1279,16 @@ def test_tracks_in_exp_pass(self):
12781279
storms = {"in": "2000233N12316", "out": "2000160N21267"}
12791280
tc_track = tc.TCTracks.from_ibtracs_netcdf(storm_id=list(storms.values()))
12801281

1281-
# Define exposure from geopandas
1282-
world = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
1282+
# Define exposure from shapefile.natural_earth
1283+
shape_file = shapereader.Reader(
1284+
shapereader.natural_earth(
1285+
resolution="110m", category="cultural", name="admin_0_countries"
1286+
)
1287+
)
1288+
world = gpd.GeoDataFrame(
1289+
data=[cntry.attributes for cntry in shape_file.records()],
1290+
geometry=[cntry.geometry for cntry in shape_file.records()],
1291+
).rename(columns=lambda col: col.lower())
12831292
exp_world = Exposures(world)
12841293
exp = Exposures(exp_world.gdf[exp_world.gdf["name"] == "Cuba"])
12851294

0 commit comments

Comments
 (0)