You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to export sfr, the locations of the cells do not overlap model grid. The dis grid retains the modelgrid coordinates but the sfr grid does not.
`
from flopy.utils.reference import SpatialReference
from flopy.discretization.structuredgrid import StructuredGrid
import flopy
from platform import python_version
print(f'python version: {python_version()}')
import geopandas as gpd
dis = gpd.read_file('GIS\ml_dis.shp')
ax = dis.plot()
ax.set_title('dis')
sf = gpd.read_file('GIS\ml_sfr.shp')
ax = sf.plot()
ax.set_title('sfr')
print(f'the total bounds for dis shapefile is: {dis.geometry.total_bounds}')
print(f'the total bounds for sfr shapefile is: {sf.geometry.total_bounds}')
`
If you'd like to avoid building a SpatialReference and then StructuredModelGrid object from scratch you could use this code snippet instead to set the coordinate info of the modelgrid that is automatically built when you load in your DIS and BAS file:
When trying to export sfr, the locations of the cells do not overlap model grid. The dis grid retains the modelgrid coordinates but the sfr grid does not.
`
from flopy.utils.reference import SpatialReference
from flopy.discretization.structuredgrid import StructuredGrid
import flopy
from platform import python_version
print(f'python version: {python_version()}')
print(f'flopy version: {flopy.version}')
delr, delc = np.ones((157))*660, np.ones((168))*660
xul = 6306015.91393092
yul = 1982413.68616024
sr = SpatialReference(delr=delr, delc=delc, xul=xul, yul=yul, units='feet',
proj4_str='EPSG:2226', rotation=0 , lenuni = 1, length_multiplier = 1.0 )
#make strurctured grid from model grid above.
mg = StructuredGrid(delc=sr.delc, delr=sr.delr, xoff=sr.xll, yoff=sr.yll, angrot=0,
epsg=2226, lenuni=1)
ml = flopy.modflow.Modflow.load('SRP_mf.nam',load_only = ['DIS','BAS6','SFR'], model_ws=workspace,verbose =False)
ml.modelgrid = mg
print('exporting dis')
ml.dis.export('GIS\ml_dis.shp',epsg=2226)
print('exporting sfr')
ml.sfr.export('GIS\ml_sfr.shp',epsg=2226)
import geopandas as gpd
dis = gpd.read_file('GIS\ml_dis.shp')
ax = dis.plot()
ax.set_title('dis')
sf = gpd.read_file('GIS\ml_sfr.shp')
ax = sf.plot()
ax.set_title('sfr')
print(f'the total bounds for dis shapefile is: {dis.geometry.total_bounds}')

print(f'the total bounds for sfr shapefile is: {sf.geometry.total_bounds}')
`
inputs.zip
The text was updated successfully, but these errors were encountered: