flopy.utils.gridgen Module

class flopy.utils.gridgen.Gridgen(dis, model_ws='.', exe_name='gridgen', surface_interpolation='replicate')

Class to work with the gridgen program to create layered quadtree grids.

Parameters:

dis : flopy.modflow.ModflowDis

Flopy discretization object

model_ws : str

workspace location for creating gridgen files (default is ‘.’)

exe_name : str

path and name of the gridgen program. (default is gridgen)

surface_interpolation : str

Default gridgen method for interpolating elevations. Valid options include ‘replicate’ (default) and ‘interpolate’

Notes

For the surface elevations, the top of a layer uses the same surface as the bottom of the overlying layer.

add_active_domain(feature, layers)
Parameters:

feature : str or list

feature can be either a string containing the name of a polygon shapefile or it can be a list of polygons

layers : list

A list of layers (zero based) for which this active domain applies.

Returns:

None

add_refinement_features(features, featuretype, level, layers)
Parameters:

features : str or list

features can be either a string containing the name of a shapefile or it can be a list of points, lines, or polygons

featuretype : str

Must be either ‘point’, ‘line’, or ‘polygon’

level : int

The level of refinement for this features

layers : list

A list of layers (zero based) for which this refinement features applies.

Returns:

None

build(verbose=False)

Build the quadtree grid

Parameters:

verbose : bool

If true, print the results of the gridgen command to the terminal (default is False)

Returns:

None

export(verbose=False)

Export the quadtree grid to shapefiles, usgdata, and vtk

Returns:None
get_center(nodenumber)

Return the cell center x and y coordinates

Parameters:nodenumber
Returns:(x, y) : tuple
get_nod_recarray()

Load the qtg.nod file and return as a numpy recarray

Returns:

node_ra : ndarray

Recarray representation of the node file with zero-based indexing

get_vertices(nodenumber)

Return a list of 5 vertices for the cell. The first vertex should be the same as the last vertex.

Parameters:nodenumber
Returns:list of vertices : list
intersect(features, featuretype, layer)
Parameters:

features : str or list

features can be either a string containing the name of a shapefile or it can be a list of points, lines, or polygons

featuretype : str

Must be either ‘point’, ‘line’, or ‘polygon’

layer : int

Layer (zero based) to intersect with. Zero based.

Returns:

result : np.recarray

Recarray of the intersection properties.

plot(ax=None, layer=0, edgecolor='k', facecolor='none', cmap='Dark2', a=None, masked_values=None, **kwargs)

Plot the grid. This method will plot the grid using the shapefile that was created as part of the build method.

Note that the layer option is not working yet.

Parameters:

ax : matplotlib.pyplot axis

The plot axis. If not provided it, plt.gca() will be used. If there is not a current axis then a new one will be created.

layer : int

Layer number to plot

cmap : string

Name of colormap to use for polygon shading (default is ‘Dark2’)

edgecolor : string

Color name. (Default is ‘scaled’ to scale the edge colors.)

facecolor : string

Color name. (Default is ‘scaled’ to scale the face colors.)

a : numpy.ndarray

Array to plot.

masked_values : iterable of floats, ints

Values to mask.

kwargs : dictionary

Keyword arguments that are passed to PatchCollection.set(**kwargs). Some common kwargs would be ‘linewidths’, ‘linestyles’, ‘alpha’, etc.

Returns:

pc : matplotlib.collections.PatchCollection

set_surface_interpolation(isurf, type, elev=None, elev_extent=None)
Parameters:

isurf : int

surface number where 0 is top and nlay + 1 is bottom

type : str

Must be ‘INTERPOLATE’, ‘REPLICATE’ or ‘ASCIIGRID’.

elev : numpy.ndarray of shape (nr, nc) or str

Array that is used as an asciigrid. If elev is a string, then it is assumed to be the name of the asciigrid.

elev_extent : list-like

list of xmin, xmax, ymin, ymax extents of the elev grid.

Returns:

None

flopy.utils.gridgen.features_to_shapefile(features, featuretype, filename)

Write a shapefile for the features of type featuretype.

Parameters:

features : list

List of point, line, or polygon features

featuretype : str

Must be ‘point’, ‘line’, or ‘polygon’

filename : string

name of the shapefile to write

Returns:

None