Utilities for Working with SMS

The preprocessing toolkit has some utilities that can help when working with Aquaveo SMS, the main form of mesh generation we use until we are able to distrubute a sufficient open source mesh generator.

Converting an SMS mesh (2dm) file to gr3

The script that converts SMS mesh to SCHISM gr3 format is available as a standalone script.

convert_mesh

schimpy provides a single conversion utility between sms, shapefiles and SMS 2dm files

Convert a mesh from one format to another. The format is decided by the extensions automatically.

usage: convert_mesh [-h] [--input INPUT] [--output OUTPUT] [--crs CRS]

Named Arguments

--input

Input mesh file

--output

Output mesh file

--crs

crs string for the projection

Getting SMS Polygons for Preprocessor

SMS is able to create mesh coverages that are not mesh generation hints, including spatial properties maps whose polygons have "material properties". If you save the coverage as a polygon shapefile, the script can help convert the resulting shapefile to the preprocessor yaml format. At the time of writing we do not have a tutorial example of this process.

convert_polygons

Convert polygon information from one file format to another

usage: convert_polygons [-h] [--input INPUT] [--output OUTPUT]

Named Arguments

--input

input file

--output

output file

Visualizing detailed bathymetry inside SMS

Earlier versions of SMS had bugs causing incorrect georefercing of DEMs and very poor memory management. That is fixed but for efficiency reasons it continues to be impossible to efficiently assign elevations within the software for a large mesh. There are several ways of tackling this, which are covered in the Bay-Delta SCHISM documentation. Here we have two scripts that were designed to help with this problem: clip_dems.py and stacked_dem_fill.py.

clip_dems

Trim each DEM on a prioritized list. The coordinates used for clipping is supplied either directly as an upper left and lower right coordinate or indirectly using the bounding coordinates of a sample image. In practice this script is usually used with images saved from SMS

usage: clip_dems [-h] [--coords ul_x ul_y lr_x lr_y] [--image INFILE]
                 [--prefix PREFIX] [--outformat OUTFORMAT] [--verbose]
                 [--hshift]
                 demlist

Positional Arguments

demlist

file containing prioritized (high to low) list of dems.

Named Arguments

--coords

bounding coordinates to which DEMs will be clipped (upper left, lower right)

Default: (None, None, None, None)

--image

image or DEM used to infer bounding coordinates for clipping. Use jpeg for the image. This argument is mutually exclusive with –coords. If a sample is provided its upper left and lower right corner will be used.

--prefix

prefix used for output file names

Default: “clipped”

--outformat

output format, default is AAIGrid (ArcInfo ascii.

Default: “AAIGrid”

--verbose

more verbose output.

Default: False

--hshift

(deprecated) shift DEM by half cell for applications that incorrectly interpret the location of the origin and data centering of a DEM. This is a bug fix for SMS < 11.1

Default: False

The script clip_dems.py is used to create mini-DEMs on the fly that are small enough to be brought into the SMS environment as rasters without slowing it down too much. The same The DEM List File is used here as elsewhere in the pre-processor.

The normal pattern of work is to zoom into the area of interst in SMS, save the work area as a jpeg image and use it as the image argument to clip_dems.py. One cut DEM will be produced for each DEM on the dem_list file that intersects the work area, using file names in order of priority (0 highest). The cut DEMs would then be imported and visualized in SMS, ideally using contours as the viewing choice and a carefully crafted color map designed to focus on the elevations that are locally most important.

stacked_dem_fill

The script stacked_dem_fill.py is the one we use to populate a mesh with elevations.

Fill node elevations in a .2dm SMS mesh or gr3 file using a prioritized list of DEMs.

usage: stacked_dem_fill [-h] [--elev2depth] [--fill FILL] filename demfile

Positional Arguments

filename

name of 2dm or gr3 file

demfile

file containing list of DEMs. These can be in any form that gdal accepts, which includes ESRI ascii format and GeoTiffs

Named Arguments

--elev2depth

Convert elevation to depth by flipping sign. This is typical when using gr3 format, less so with 2dm.

Default: False

--fill

Fill value for areas not covered by supplied rasters.

Default: 2.0