File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1132,10 +1132,8 @@ def write_hdf5(self, file_name):
11321132 """
11331133 LOGGER .info ("Writing %s" , file_name )
11341134 store = pd .HDFStore (file_name , mode = "w" )
1135- pandas_df = pd .DataFrame (self .gdf )
11361135 geocols = self .gdf .columns [self .gdf .dtypes == "geometry" ].to_list ()
1137- for col in geocols :
1138- pandas_df [col ] = gpd .GeoSeries (pandas_df [col ]).to_wkb ()
1136+ pandas_df = self .data .to_wkb ()
11391137
11401138 # Avoid pandas PerformanceWarning when writing HDF5 data
11411139 with warnings .catch_warnings ():
Original file line number Diff line number Diff line change @@ -384,6 +384,9 @@ def test_io_hdf5_pass(self):
384384 exp .ref_year = 2020
385385 exp .value_unit = "XSD"
386386
387+ # add another geometry column
388+ exp .data ["geocol2" ] = exp .data .geometry .copy (deep = True )
389+
387390 file_name = DATA_DIR .joinpath ("test_hdf5_exp.h5" )
388391
389392 # pd.errors.PerformanceWarning should be suppressed. Therefore, make sure that
@@ -431,7 +434,12 @@ def test_io_hdf5_pass(self):
431434 u_coord .equal_crs (exp .crs , exp_read .crs ),
432435 f"{ exp .crs } and { exp_read .crs } are different" ,
433436 )
434- self .assertTrue (u_coord .equal_crs (exp .gdf .crs , exp_read .gdf .crs ))
437+ self .assertTrue (u_coord .equal_crs (exp .data .crs , exp_read .data .crs ))
438+
439+ self .assertTrue (exp_read .data ["geocol2" ].dtype == "geometry" )
440+ np .testing .assert_array_equal (
441+ exp .data ["geocol2" ].geometry , exp_read .data ["geocol2" ].values
442+ )
435443
436444
437445class TestAddSea (unittest .TestCase ):
You can’t perform that action at this time.
0 commit comments