Class GridUtilities
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
compatibleGrids
(GridData grid1, GridData grid2) compares the coordinate system, cell size, and row and column positioning of two grids to determine if they are compatible for grid-to-grid operations.static GridData
Calculates the results of a cell-by-cell (map algebra) add on two compatible grids.static GridData
gridDivide
(GridData grid1, GridData grid2, int[] status) Calculates the results of a cell-by-cell (map algebra) divide on two compatible grids.static GridData
gridMultiply
(GridData grid1, GridData grid2, int[] status) Calculates the results of a cell-by-cell (map algebra) multiply on two compatible grids.static GridData
gridSubtract
(GridData grid1, GridData grid2, int[] status) Calculates the results of a cell-by-cell (map algebra) subtract on two compatible grids.static int[]
intersectExtent
(GridData grid1, GridData grid2) Calculates the extent of the intersection of two compatible grids.static boolean
isGridType
(int type) static GridData
Creates a new GridData object of the same type (HRAP, Albers, etc) as its input with new extents as specified by the row and column numbers named in its parameters.static GridData
retrieveGridFromDss
(String dssFileName, String path, int[] status) High-level call to retrieve a GridData object from a given DSS file and path.static GridData
adds the value of addend to each non-null cell in the input grid and creates a new GridData object to hold the result.static GridData
scalarDivide
(GridData inGrid, float divisor) divides the value of each non-null cell in the input grid by divisor and creates a new GridData object to hold the result.static GridData
scalarMultiply
(GridData inGrid, float factor) multiplies the value of each non-null cell in the input grid by factor and creates a new GridData object to hold the result.static GridData
scalarSubtract
(GridData inGrid, float subtrahend) subtracts the value of subtrahend from each non-null cell in the input grid and creates a new GridData object to hold the result.static int
setTimeByEnd
(GridData theGrid, HecTime endTime) changes the start and end times of a GridData object, by specifying the new end time.static int
setTimeByStart
(GridData theGrid, HecTime startTime) changes the start and end times of a GridData object by specifying the new start time.static int
storeGridToDss
(String dssFileName, String path, GridData theGrid) High-level call to store a GridData object in a given DSS file and path.static GridData
subGridExtract
(GridData inGrid, int xOrigin, int yOrigin, int xExtent, int yExtent, int[] status) Creates a new GridData object of the same type (HRAP, Albers, etc) as its input with new extents as specified by the row and column numbers named in its parameters.static int[]
unionExtent
(GridData grid1, GridData grid2) Calculates the extent of the union of two compatible grids.
-
Constructor Details
-
GridUtilities
public GridUtilities()
-
-
Method Details
-
isGridType
public static boolean isGridType(int type) - Parameters:
type
- -- an integer representing and HEC-DSS data type- Returns:
- -- True if the data type is a grid type, otherwise False
-
compatibleGrids
compares the coordinate system, cell size, and row and column positioning of two grids to determine if they are compatible for grid-to-grid operations.- Parameters:
grid1
-grid2
-- Returns:
- boolean
-
storeGridToDss
High-level call to store a GridData object in a given DSS file and path.The D and E parts of the path will be re-set to match the start and end time of the grid as given in the GridInfo object that's part of the GridData.
- Parameters:
dssFileName
- -- New or existing DSS filepath
- -- DSS path in one stringtheGrid
- -- a GridData object ready to store- Returns:
- 0 - grid successfully stored to DSS file
-
retrieveGridFromDss
High-level call to retrieve a GridData object from a given DSS file and path.On return, the value of status[0] is 0 if the retrieval is successful, -1 if the file or path can't be accessed, or -2 if the path exists but is not a grid.
- Parameters:
dssFileName
- -- New or existing DSS filepath
- -- DSS path in one stringstatus
- -- an integer array that will hold a status value- Returns:
- -- a new gridData object
-
setTimeByStart
changes the start and end times of a GridData object by specifying the new start time. For instantaneous grids, both start and end times are set to the new time. For period grids, the method maintains the interval between start and end times to the nearest minute.Note that for instantaneous grids, SetTimeFromStart and SetTimeFromEnd do exactly the same thing.
- Parameters:
theGrid
- theGrid -- This is the object being changedstartTime
- theTime -- This is the new end time for the grid- Returns:
- 0 for success
-
setTimeByEnd
changes the start and end times of a GridData object, by specifying the new end time. For instantaneous grids, both start and end times are set to the new time. For period grids, the method maintains the interval between start and end times to the nearest minute.Note that for instantaneous grids, SetTimeFromStart and SetTimeFromEnd do exactly the same thing.
- Parameters:
theGrid
- theGrid -- This is the object being changedendTime
- theTime -- This is the new end time for the grid- Returns:
- 0 for success
-
scalarAdd
adds the value of addend to each non-null cell in the input grid and creates a new GridData object to hold the result.- Parameters:
inGrid
-addend
-- Returns:
-
scalarSubtract
subtracts the value of subtrahend from each non-null cell in the input grid and creates a new GridData object to hold the result.- Parameters:
inGrid
-subtrahend
-- Returns:
-
scalarMultiply
multiplies the value of each non-null cell in the input grid by factor and creates a new GridData object to hold the result.- Parameters:
inGrid
-factor
-- Returns:
-
scalarDivide
divides the value of each non-null cell in the input grid by divisor and creates a new GridData object to hold the result.- Parameters:
inGrid
-divisor
-- Returns:
-
subGridExtract
public static GridData subGridExtract(GridData inGrid, int xOrigin, int yOrigin, int xExtent, int yExtent, int[] status) Creates a new GridData object of the same type (HRAP, Albers, etc) as its input with new extents as specified by the row and column numbers named in its parameters.This method does not do any coordinate transformations.
The method checks the subgrid extents against the input grid extents and throws an IndexOutOfBounds exception if the range of sub-grid cell indices lies all or partly outside the bounds of the input grid.
- Parameters:
inGrid
-xOrigin
- -- column index of subgrid originyOrigin
- -- row index of subgrid originxExtent
- -- number of columns in subgridyExtent
- -- number of rows in subgridstatus
- -- an integer array that will hold a status value- Returns:
-
mosaic
Creates a new GridData object of the same type (HRAP, Albers, etc) as its input with new extents as specified by the row and column numbers named in its parameters.This method does not do any coordinate transformations.
The GridInfo for the product grid is initially copied from the first input grid, so the times, units, data type, etc. are set by grid1.
- Parameters:
inGrid1
-inGrid2
-status
- -- an integer array that will hold a status value- Returns:
-
intersectExtent
Calculates the extent of the intersection of two compatible grids. The result is returned as an array of four integers. If the grids are not compatible, all four values are set to zero- Parameters:
grid1
- GridData objectgrid2
- GridData object- Returns:
- int array representing origin indices and width and height in rows and columns [x-Origin, y-Origin, number of columns, number of rows]
-
unionExtent
Calculates the extent of the union of two compatible grids. The extent is returned as an array of four integers. If the grids are not compatible, all four values are set to zero- Parameters:
grid1
- GridData objectgrid2
- GridData object- Returns:
- int array representing origin indices and width and height in rows and columns [x-Origin, y-Origin, number of columns, number of rows]
-
gridMultiply
Calculates the results of a cell-by-cell (map algebra) multiply on two compatible grids. If the grids are not compatible or do not intersect, a null object is returned.The GridInfo for the product grid is initially copied from the first input grid, so the times, units, data type, etc. are set by grid1.
- Parameters:
grid1
- GridData objectgrid2
- GridData objectstatus
- int[] 0 for success; non-zero for error- Returns:
- GridData object
-
gridDivide
Calculates the results of a cell-by-cell (map algebra) divide on two compatible grids. If the grids are not compatible or do not intersect, a null object is returned.The GridInfo for the product grid is initially copied from the first input grid, so the times, units, data type, etc. are set by grid1.
- Parameters:
grid1
- GridData objectgrid2
- GridData objectstatus
- int[] 0 for success; non-zero for error- Returns:
- GridData object
-
gridAdd
Calculates the results of a cell-by-cell (map algebra) add on two compatible grids. If the grids are not compatible or do not intersect, a null object is returned.The GridInfo for the product grid is initially copied from the first input grid, so the times, units, data type, etc. are set by grid1.
- Parameters:
grid1
- GridData objectgrid2
- GridData objectstatus
- int[] 0 for success; non-zero for error- Returns:
- GridData object
-
gridSubtract
Calculates the results of a cell-by-cell (map algebra) subtract on two compatible grids. If the grids are not compatible or do not intersect, a null object is returned.The GridInfo for the product grid is initially copied from the first input grid, so the times, units, data type, etc. are set by grid1.
- Parameters:
grid1
- GridData objectgrid2
- GridData objectstatus
- int[] 0 for success; non-zero for error- Returns:
- GridData object
-