WMS Dataset Files

File extensions: Variable (e.g.: dep and swe)

This file object supports spatial objects.

File Object

class gsshapy.orm.WMSDatasetFile[source]

Bases: sqlalchemy.ext.declarative.api.Base, gsshapy.base.file_base.GsshaPyFileObjectBase

Object interface for WMS Dataset Files.

The WMS dataset file format is used to store gridded timeseries output data for GSSHA. The file contents are abstracted into one other object: WMSDatasetRaster. The WMS dataset contains a raster for each time step that output is written.

Note: only the scalar form of the WMS dataset file is supported.

See: http://www.xmswiki.com/xms/WMS:ASCII_Dataset_Files

tableName = u'wms_dataset_files'

Database tablename

id

PK

projectFileID

FK

type

INTEGER

fileExtension

STRING

objectType

STRING

vectorType

STRING

objectID

INTEGER

numberData

INTEGER

numberCells

INTEGER

name

STRING

projectFile

RELATIONSHIP

rasters

RELATIONSHIP

read(directory, filename, session, maskMap, spatial=False, spatialReferenceID=4236)[source]

Read file into the database.

write(session, directory, name, maskMap)[source]

Write from database to file.

session = SQLAlchemy session object

directory = to which directory will the files be written (e.g.: ‘/example/path’)

name = name of file that will be written (e.g.: ‘my_project.ext’)

getAsKmlGridAnimation(session, projectFile=None, path=None, documentName=None, colorRamp=None, alpha=1.0, noDataValue=0.0)[source]

Retrieve the WMS dataset as a gridded time stamped KML string.

Parameters:
  • session (sqlalchemy.orm.session.Session) – SQLAlchemy session object bound to PostGIS enabled database.
  • projectFile (gsshapy.orm.ProjectFile) – Project file object for the GSSHA project to which the WMS dataset belongs.
  • path (str, optional) – Path to file where KML file will be written. Defaults to None.
  • documentName (str, optional) – Name of the KML document. This will be the name that appears in the legend. Defaults to ‘Stream Network’.
  • colorRamp (mapkit.ColorRampGenerator.ColorRampEnum or dict, optional) – Use ColorRampEnum to select a default color ramp or a dictionary with keys ‘colors’ and ‘interpolatedPoints’ to specify a custom color ramp. The ‘colors’ key must be a list of RGB integer tuples (e.g.: (255, 0, 0)) and the ‘interpolatedPoints’ must be an integer representing the number of points to interpolate between each color given in the colors list.
  • alpha (float, optional) – Set transparency of visualization. Value between 0.0 and 1.0 where 1.0 is 100% opaque and 0.0 is 100% transparent. Defaults to 1.0.
  • noDataValue (float, optional) – The value to treat as no data when generating visualizations of rasters. Defaults to 0.0.
Returns:

KML string

Return type:

str

getAsKmlPngAnimation(session, projectFile=None, path=None, documentName=None, colorRamp=None, alpha=1.0, noDataValue=0, drawOrder=0, cellSize=None, resampleMethod=u'NearestNeighbour')[source]

Retrieve the WMS dataset as a PNG time stamped KMZ

Parameters:
  • session (sqlalchemy.orm.session.Session) – SQLAlchemy session object bound to PostGIS enabled database.
  • projectFile (gsshapy.orm.ProjectFile) – Project file object for the GSSHA project to which the WMS dataset belongs.
  • path (str, optional) – Path to file where KML file will be written. Defaults to None.
  • documentName (str, optional) – Name of the KML document. This will be the name that appears in the legend. Defaults to ‘Stream Network’.
  • colorRamp (mapkit.ColorRampGenerator.ColorRampEnum or dict, optional) – Use ColorRampEnum to select a default color ramp or a dictionary with keys ‘colors’ and ‘interpolatedPoints’ to specify a custom color ramp. The ‘colors’ key must be a list of RGB integer tuples (e.g.: (255, 0, 0)) and the ‘interpolatedPoints’ must be an integer representing the number of points to interpolate between each color given in the colors list.
  • alpha (float, optional) – Set transparency of visualization. Value between 0.0 and 1.0 where 1.0 is 100% opaque and 0.0 is 100% transparent. Defaults to 1.0.
  • noDataValue (float, optional) – The value to treat as no data when generating visualizations of rasters. Defaults to 0.0.
  • drawOrder (int, optional) – Set the draw order of the images. Defaults to 0.
  • cellSize (float, optional) – Define the cell size in the units of the project projection at which to resample the raster to generate the PNG. Defaults to None which will cause the PNG to be generated with the original raster cell size. It is generally better to set this to a size smaller than the original cell size to obtain a higher resolution image. However, computation time increases exponentially as the cell size is decreased.
  • resampleMethod (str, optional) – If cellSize is set, this method will be used to resample the raster. Valid values include: NearestNeighbour, Bilinear, Cubic, CubicSpline, and Lanczos. Defaults to NearestNeighbour.
Returns:

Returns a KML string and a list of binary strings that are the PNG images.

Return type:

(str, list)

Supporting Objects

class gsshapy.orm.WMSDatasetRaster[source]

Bases: sqlalchemy.ext.declarative.api.Base, gsshapy.base.rast.RasterObjectBase

Object storing a single raster dataset for a WMS dataset file.

This object inherits several methods from the gsshapy.orm.RasterObjectBase base class for generating raster visualizations. These methods can be used to generate individual raster visualizations for specific time steps.

tableName = u'wms_dataset_rasters'

Database tablename

id

PK

timeStep

INTEGER

timestamp

FLOAT

iStatus

INTEGER

rasterText

STRING

raster

RASTER

getAsWmsDatasetString(session)[source]

Retrieve the WMS Raster as a string in the WMS Dataset format