Bay-Delta SELFE Tools

stacked_dem_fill Module

Module contains routines to fill elevation (or other scalar) values at points from a prioritized list of rasters

Depends on GDAL for loading values. GDAL is easily installed with no tertiary dependencies.

The module requires Python 2.6

stacked_dem_fill.ParseType(type)
stacked_dem_fill.Usage()
stacked_dem_fill.bilinear(points, gt, raster)

Bilinear interpolated point at (px, py) using data on raster points: npoint x 3 array of (x,y,z points) gt: geotransform information from gdal raster: the data

stacked_dem_fill.create_arg_parser()
stacked_dem_fill.filelist_main(demlistfile, pointlistfile, sep='')

higher level driver routine that parses the names of the DEMs from demfilelist points ( x,y or x,y,z ) from pointlistfile

stacked_dem_fill.fill_2dm(infile, outfile, demlist)
stacked_dem_fill.fill_gr3(infile, outfile, demlist, elev2depth=True)
stacked_dem_fill.stacked_dem_fill(files, points, negate=False, require_all=True, na_fill=None)

Fill values at an array of points using bilinear interpolation from a prioritized stack of dems. This routine controls prioritization of the dems, gradually filling points that are still marked “nan”

files: list of files. Existance is checked and ValueError for bad file points: this is a numpy array of points, nrow = # points and ncol = 3 (x,y,z). The z column is filled in-place negate: if True, values will be inverted (from elevation to depth) require_all: if True, a ValueError is raised if the list of DEMs does not cover all the points. In either case (True/False)

a file is created or overwritten (“dem_misses.txt”) that will show all the misses.
na_fill: value to substitute at the end for values that are NA after all DEMs are processed.
If require_all = True na_fill must be None
stacked_dem_fill.test_main()