PySCHISM: TypeError in fgrid.py: 'sjoin() got an unexpected keyword argument 'op''
I encountered a TypeError in fgrid.py when trying to use the modify_by_region method in PySCHISM. The error message indicates that sjoin() got an unexpected keyword argument 'op'. This issue seems to be caused by a change in the geopandas API, where the op parameter has been replaced by predicate.
Steps to Reproduce
Run the following code:
from pyschism.mesh.hgrid import Hgrid
from pyschism.mesh.fgrid import DragCoefficient
if __name__ == '__main__':
hgrid=Hgrid.open('hgrid.gr3', crs='epsg:4326')
depth1=-1.0
depth2=-3.0
bfric_river=0.0025
bfric_land=0.025
fgrid=DragCoefficient.linear_with_depth(hgrid, depth1, depth2, bfric_river, bfric_land)
regions=['region1.reg', 'region2.reg']
values=[0.001, 0.0]
flags=[1, 0]
for reg, value, flag in zip(regions, values, flags):
fgrid.modify_by_region(hgrid, f'./{reg}', value, depth1, flag)
fgrid.write('drag.gr3', overwrite=True)
The error occurs on this line in fgrid.py:
gdf_in = gpd.sjoin(gdf2, gdf1, op="within")
Proposed Fix
The issue can be fixed by replacing op with predicate:
@mansurjisan can you test the update in PR and see if it resolves the issues. Unfortunately pyschism doesn't yet have any automated tests, so we need manual testing to confirm it works. See #131
PySCHISM: TypeError in fgrid.py: 'sjoin() got an unexpected keyword argument 'op''
I encountered a
TypeError
infgrid.py
when trying to use themodify_by_region
method in PySCHISM. The error message indicates thatsjoin()
got an unexpected keyword argument 'op'. This issue seems to be caused by a change in thegeopandas
API, where theop
parameter has been replaced bypredicate
.Steps to Reproduce
Proposed Fix
The issue can be fixed by replacing op with predicate:
Additional Information
PySCHISM version: 0.1.15 Geopandas version: 1.0.1 Python version: 3.9.19