@@ -159,7 +159,7 @@ def get_icell2d_from_xy(x, y, ds, gi=None, rotated=True):
159159 gi = flopy .utils .GridIntersect (
160160 modelgrid_from_ds (ds , rotated = rotated )
161161 )
162- cellids = gi .intersects (Point (x , y ))["cellids " ]
162+ cellids = gi .intersects (Point (x , y ), dataframe = True )["cellid " ]
163163 if len (cellids ) < 1 :
164164 raise (ValueError (f"Point ({ x } , { y } ) is outside of the model grid" ))
165165 icell2d = cellids [0 ]
@@ -227,7 +227,7 @@ def get_row_col_from_xy(x, y, ds, rotated=True, gi=None):
227227 msg = "get_row_col_from_xy can only be applied to a structured grid"
228228 assert ds .gridtype == "structured" , msg
229229 if gi is not None :
230- cellids = gi .intersects (Point (x , y ))[ "cellids" ]
230+ cellids = gi .intersects (Point (x , y ), dataframe = True )[[ "row" , "col" ]]. values
231231 if len (cellids ) < 1 :
232232 raise (ValueError (f"Point ({ x } , { y } ) is outside of the model grid" ))
233233 row , col = cellids [0 ]
@@ -1907,18 +1907,17 @@ def gdf_to_count_da(gdf, ds, ix=None, buffer=0.0, **kwargs):
19071907
19081908 for geom in geoms :
19091909 if buffer > 0.0 :
1910- cids = ix .intersects (geom .buffer (buffer ), ** kwargs )[ "cellids" ]
1910+ df = ix .intersects (geom .buffer (buffer ), dataframe = True , ** kwargs )
19111911 else :
1912- cids = ix .intersects (geom , ** kwargs )[ "cellids" ]
1912+ df = ix .intersects (geom , dataframe = True , ** kwargs )
19131913
1914- if len (cids ) == 0 :
1914+ if len (df ) == 0 :
19151915 continue
19161916
19171917 if ds .gridtype == "structured" :
1918- ixs , iys = zip (* cids )
1919- da .values [ixs , iys ] += 1
1918+ da .values [df ['row' ], df ['col' ]] += 1
19201919 elif ds .gridtype == "vertex" :
1921- da [cids . astype ( int ) ] += 1
1920+ da [df [ 'cellid' ] ] += 1
19221921
19231922 return da
19241923
@@ -2133,7 +2132,7 @@ def gdf_area_to_da(
21332132 df = ix .intersect (gdf .at [index , geometry ], geo_dataframe = True , ** kwargs )
21342133 if structured :
21352134 for i in range (df .shape [0 ]):
2136- data [df [ "cellids" ][ i ] + (irow ,)] += df ["areas" ][i ]
2135+ data [df . iloc [ i ][ "cellid" ] + (irow ,)] += df ["areas" ][i ]
21372136 else :
21382137 data [list (df ["cellids" ]), irow ] = df ["areas" ]
21392138
0 commit comments