GeoEco.Datasets.Virtual.ClippedGrid
- class GeoEco.Datasets.Virtual.ClippedGrid(grid, clipBy='Cell indices', xMin=None, xMax=None, yMin=None, yMax=None, zMin=None, zMax=None, tMin=None, tMax=None)
Bases:
GridA
Gridthat trims aGridto a smaller spatiotemporal extent.- Parameters:
grid (
Grid) – Grid to clip.clipBy (
str, optional) –Specifies the type of extent values that will be used to clip the grid, one of:
Map coordinates- the values are coordinates in space and time. Typically this means that x and y coordinates will be in degrees (if a geographic coordinate system is used) or a linear unit such as meters (if a projected coordinate system is used), the z (depth) coordinate will be in a linear unit such as meters, and the t (time) coordinate will be a date and time string in a standard format such asYYYY-MM-DD HH:MM:SS, or a Pythondatetimeinstance.Indices- the values are integer indices of cells in the grid, starting at 0 and ending at the maximum index value. For example, if a 2D grid has 360 columns and 180 rows, the x and y indices will range from 0 to 359 and 0 to 179, respectively.
If
Indicesis specified but floating point numbers are provided for the extent values, the decimal portions of the numbers will be truncated (e.g. the value 1.7 will be truncated to 1).If
Map coordinatesis specified and a coordinate value falls within a cell, rather than exactly on a boundary between two cells, the cell will be included in the clipped grid (it will not be clipped out). Because computers cannot represent all floating-point numbers at full precision, the resulting rounding errors can sometimes produce unexpected results. For example, consider a grid with a cell size of 0.1. We expect that the cells centered at 0.5 and 1.5 would meet at coordinate value 0.1, but 0.1 cannot be fully represented by the computer using standard 64-bit floating-point numbers. The computer rounds it to 0.10000000000000001. Therefore, if you were to clip the grid a maximum coordinate of 0.10000000000000001, you would expect that the cell centered at 1.5 would be included in the resulting grid, because 0.10000000000000001 falls within that cell. But the computer actually considers the boundary between the two cells to be at 0.10000000000000001, not 0.1, so that cell would be clipped out.Allowed values꞉
'Map coordinates','Cell indices'.xMin (
float, optional) – Minimum x coordinate or index. The Clip By parameter determines whether the value is a coordinate or an index. If a coordinate is provided, it may be an integer or a floating point number. If an index is provided, it must be an non-negative integer. If a value is not provided, the clipped grid will extend to the full extent in the negative x direction.xMax (
float, optional) – Maximum x coordinate or index. The Clip By parameter determines whether the value is a coordinate or an index. If a coordinate is provided, it may be an integer or a floating point number. If an index is provided, it must be an non-negative integer. If a value is not provided, the clipped grid will extend to the full extent in the positive x direction.yMin (
float, optional) – Minimum y coordinate or index. The Clip By parameter determines whether the value is a coordinate or an index. If a coordinate is provided, it may be an integer or a floating point number. If an index is provided, it must be an non-negative integer. If a value is not provided, the clipped grid will extend to the full extent in the negative y direction.yMax (
float, optional) – Maximum y coordinate or index. The Clip By parameter determines whether the value is a coordinate or an index. If a coordinate is provided, it may be an integer or a floating point number. If an index is provided, it must be an non-negative integer. If a value is not provided, the clipped grid will extend to the full extent in the positive y direction.zMin (
float, optional) – Minimum z coordinate or index. The Clip By parameter determines whether the value is a coordinate or an index. If a coordinate is provided, it may be an integer or a floating point number. If an index is provided, it must be an non-negative integer. If a value is not provided, the clipped grid will extend to the full extent in the negative z direction.zMax (
float, optional) – Maximum z coordinate or index. The Clip By parameter determines whether the value is a coordinate or an index. If a coordinate is provided, it may be an integer or a floating point number. If an index is provided, it must be an non-negative integer. If a value is not provided, the clipped grid will extend to the full extent in the positive z direction.tMin (
object, optional) – Minimum t coordinate or index. The Clip By parameter determines whether the value is a coordinate or an index. If a coordinate is provided, it may be a date and time string in a standard format such asYYYY-MM-DD HH:MM:SSor a Pythondatetimeinstance. If an index is provided, it must be an non-negative integer. If a value is not provided, the clipped grid will extend to the full extent in the negative t direction.tMax (
object, optional) – Maximum t coordinate or index. The Clip By parameter determines whether the value is a coordinate or an index. If a coordinate is provided, it may be a date and time string in a standard format such asYYYY-MM-DD HH:MM:SSor a Pythondatetimeinstance. If an index is provided, it must be an non-negative integer. If a value is not provided, the clipped grid will extend to the full extent in the positive t direction.
- Returns:
ClippedGridinstance.- Return type:
Properties
- property CenterCoords
(
object) Coordinates of the grid cell centers, indexed using the 1-character dimension of interest and optionally arangeto retrieve anumpy.ndarrayof coordinates (e.g.CenterCoords['x', 0:4]) or an integer to retrieve afloatfor a single coordinate (e.g.CenterCoords['x', 10]). Coordinates for thetdimension are returned asdatetimeinstances. Read only.
- property CoordDependencies
(
tupleofstr) Same length asDimensions. Dimensions that each dimension depends on for determining its coordinates.Nonefor dimensions that have a constant coordinate increment. Read only.
- property CoordIncrements
(
tupleoffloat) Same length asDimensions. Coordinate increment for each dimension.Nonefor dimensions that do not have a constant coordinate increment. Read only.
- property Data
(
object) This grid’s data, indexable using slices (e.g.grid.Data[:, 5:10, -10:]) or integers (e.g.grid.Data[0,1,-2]) or both in combination. Strides and negative indexes are supported in the traditional manner. If the grid is writable,Datacan be assigned to write values to the grid, e.g.grid.Data[0,1] = 5orgrid.Data[:,:] = numpy.zeros(grid.Shape). Returns and acceptsnumpy.ndarray,float, andint. Read only.
- property DataIsScaled
(
bool) If True, the underlying raw data are stored as theUnscaledDataTypeto save storage space and then transformed by a scaling equation on the fly when they are returned byData. The raw data can be accessed withUnscaledData. If False, the raw data are returned as is, with no transformation needed, andUnscaledDataTypeandDataTypeare the same, andUnscaledDatareturns the same values asData. Read only.
- property DataType
(
str) Numeric data type of the grid, after the scaling function (if any) has been applied to the raw data.numpy.ndarrays returned byDatahave this type. Read only. Allowed values꞉'int8','uint8','int16','uint16','int32','uint32','float32','float64'. Case sensitive.
- property Dimensions
(
str) Dimensions of this grid. Read only. Allowed values꞉'yx','zyx','tyx','tzyx'. Case sensitive.
- property DisplayName
(
str) Informal name of this object, suitable to be displayed to the user. Read only. Minimum length꞉ 1.
- property MaxCoords
(
object) Maximum coordinate value for each cell (i.e., the coordinates of the cells’ right edges), indexed using the 1-character dimension of interest and optionally arangeto retrieve anumpy.ndarrayof coordinates (e.g.MaxCoords['x', 0:4]) or an integer to retrieve afloatfor a single coordinate (e.g.MaxCoords['x', 10]). Coordinates for thetdimension are returned asdatetimeinstances. Read only.
- property MinCoords
(
object) Minimum coordinate value for each cell (i.e., the coordinates of the cells’ left edges), indexed using the 1-character dimension of interest and optionally arangeto retrieve anumpy.ndarrayof coordinates (e.g.MinCoords['x', 0:4]) or an integer to retrieve afloatfor a single coordinate (e.g.MinCoords['x', 10]). Coordinates for thetdimension are returned asdatetimeinstances. Read only.
- property NoDataValue
(
objectorNone)int,float, or single-element numpy array giving the value that indicates that cells ofDatashould be interpreted as having no data (these are also known as missing, NA, or NULL cells), orNoneif all cells must have data. Read only.
- property ParentCollection
(
DatasetCollectionorNone) ParentDatasetCollectionthat this object is part of (if any). Read only.
- property Shape
(
tupleofint) Same length asDimensions. Length (number of grid cells) of each dimension. Read only.
- property TCountPerSemiRegularPeriod
(
intorNone) Number of time slices per semi-regular period (i.e. per year).Noneif the grid’s dimensions do not contain atcoordinate or thetcoordinate is not semi-regular. Read only.
- property TIncrementUnit
(
strorNone) Unit of thetcoordinate.Noneif the grid’s dimensions do not contain atcoordinate. Read only. Allowed values꞉'year','month','day','hour','minute','second'. Case sensitive.
- property TSemiRegularity
(
strorNone) Type of semi-regularity used for thetcoordinate.Noneif the grid’s dimensions do not contain atcoordinate or thetcoordinate is not semi-regular. Read only. Allowed values꞉'annual'. Case sensitive.
- property UnscaledData
(
object) This grid’s data underlying raw data, before it has been transformed by a scaling equation.UnscaledDatais indexable using slices (e.g.grid.UnscaledData[:, 5:10, -10:]) or integers (e.g.grid.UnscaledData[0,1,-2]) or both in combination. Strides and negative indexes are supported in the traditional manner. If the grid is writable,UnscaledDatacan be assigned to write values to the grid, e.g.grid.UnscaledData[0,1] = 5orgrid.UnscaledData[:,:] = numpy.zeros(grid.Shape). Returns and acceptsnumpy.ndarray,float, andint. Read only.
- property UnscaledDataType
(
str) Numeric data type of the grid’s raw data, before it has been transformed by a scaling equation.numpy.ndarrays returned byUnscaledDatahave this type. If no transformation is needed (DataIsScaledis False), thenUnscaledDataTypeandScaledDataTypeare the same, andUnscaledDatareturns the same values asData. Read only. Allowed values꞉'int8','uint8','int16','uint16','int32','uint32','float32','float64'. Case sensitive.
- property UnscaledNoDataValue
(
objectorNone)intorfloatvalue that indicates that cells ofUnscaledDatashould be interpreted as having no data (these are also known as missing, NA, or NULL cells), orNoneif all cells must have data. Read only.
Methods
Closes any open files or connections associated with this object and releases any other resources allocated to access it.
Converts a spatial reference from one format to another, such as an OGC WKT string to a Proj4 string.
Deletes the lazy property with the specified name.
Returns a list of all queryable attributes.
Given a
tupleorlistof coordinates, returns alistofintindices intoDatafor the cell that contains the coordinates.Returns the value of the lazy property with the specified name.
Returns the queryable attribute with the specified name.
Returns the value of the queryable attribute with the specified name.
Returns a list queryable attributes having the specified data type.
Returns the spatial reference of this dataset.
Returns True if the specified lazy property has a value.
Sets the lazy property with the specified name to the specified value.
Sets the spatial reference of this dataset.
Tests whether a capability is supported by this class or an instance of it.