GeoEco.Datasets.NumpyGrid
- class GeoEco.Datasets.NumpyGrid(numpyArray, displayName, spatialReference, dimensions, coordIncrements, cornerCoords, unscaledNoDataValue=None, tIncrementUnit=None, tSemiRegularity=None, tCountPerSemiRegularPeriod=None, tCornerCoordType=None, tOffsetFromParsedTime=None, coordDependencies=None, physicalDimensions=None, physicalDimensionsFlipped=None, scaledDataType=None, scaledNoDataValue=None, scalingFunction=None, unscalingFunction=None, parentCollection=None, queryableAttributes=None, queryableAttributeValues=None, lazyPropertyValues=None)
Bases:
GridWraps a
numpy.ndarrayin theGridinterface.NumpyGridprovides a convenient mechanism for modifying aGrid. The typical usage pattern is:Obtain a
Gridinstance from somewhere (e.g. aGDALRasterBandor anArcGISRasterBandinstance).Call
NumpyGrid.CreateFromGrid()to wrap theGridin aNumpyGrid.Import the
NumpyGridinto the desiredDatasetCollection.
- Parameters:
numpyArray (instance of <class 'object'>) –
numpy.ndarrayto wrap. This array must have 2, 3, or 4 dimensions. Note that the array is not copied. Data written toDatawill written to the original array provided by the caller. This array must have one of the following dtypes꞉'int8','uint8','int16','uint16','int32','uint32','float32','float64'.displayName (
str) – Informal name of this object, suitable to be displayed to the user. Minimum length꞉ 1.spatialReference (
object) – Spatial reference of the requested type as anosgeo.osr.SpatialReferenceinstance, orNoneto indicate the spatial reference is unknown.dimensions (
str) – Dimensions of this grid. Allowed values꞉'yx','zyx','tyx','tzyx'. Case sensitive.coordIncrements (
tupleoffloat) – Coordinate increment for each dimension.Nonefor dimensions that do not have a constant coordinate increment. Must have the same length as dimensions.cornerCoords (
tupleofobject) – The center coordinates of the lower-left cell of this grid. Must have the same length as dimensions.unscaledNoDataValue (
object, optional) –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.tIncrementUnit (
str, optional) – Unit of thetcoordinate.Noneif the grid’s dimensions do not contain atcoordinate. Allowed values꞉'year','month','day','hour','minute','second'. Case sensitive.tSemiRegularity (
str, optional) – Type of semi-regularity used for thetcoordinate.Noneif the grid’s dimensions do not contain atcoordinate or thetcoordinate is not semi-regular. Allowed values꞉'annual'. Case sensitive.tCountPerSemiRegularPeriod (
int, optional) – 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.tCornerCoordType (
str, optional) – Indicates whether thetcoordinate of cornerCoords is the minimum, center, or maximum coordinate for the cell. Ignored if dimensions does not have atcoordinate. Allowed values꞉'min','center','max'. Case sensitive.tOffsetFromParsedTime (
float, optional) – Number of seconds to to add totcoordinates after computing them from cornerCoords and coordIncrements. Used for datasets that round off their times, e.g. the file name contains the year, month, and day, but the time slices do not start at midnight. IfNone, nothing will be added.coordDependencies (
tupleofstr, optional) – Dimensions that each dimension depends on for determining its coordinates.Nonefor dimensions that have a constant coordinate increment. Must have the same length as dimensions.physicalDimensions (
str, optional) – The dimensions physically used by numpyArray. If they do not conform the canonical order given by dimensions, provide their actual order here andGridwill automatically reorder them as needed. Allowed values꞉'yx','xy','zyx','zxy','yzx','yxz','xzy','xyz','tyx','txy','ytx','yxt','xty','xyt','tzyx','tzxy','tyzx','tyxz','txzy','txyz','ztyx','ztxy','zytx','zyxt','zxty','zxyt','ytzx','ytxz','yztx','yzxt','yxtz','yxzt','xtzy','xtyz','xzty','xzyt','xytz','xyzt'. Case sensitive.physicalDimensionsFlipped (
tupleofbool, optional) –tupleofboolindicating how the data of in numpyArray are ordered for each physical dimension. If False, the dimension is ordered in ascending coordinate order; if True, it is in descending coordinate order. Must have the same length as dimensions.scaledDataType (
str, optional) – 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. Allowed values꞉'int8','uint8','int16','uint16','int32','uint32','float32','float64'. Case sensitive.scaledNoDataValue (
object, optional) –intorfloatvalue 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.scalingFunction (
object, optional) – Lambda or function for transforming the data of numpyArray before it is returned byData, orNoneof no such transformation is needed. The function must take one argument, a slice of numpyArray, and return anumpy.ndarrayof the scaledDataType.unscalingFunction (
object, optional) – Lambda or function for back-transforming data written toData(e.g.grid.Data[...] = ...) before it is written to numpyArray, orNoneof no such transformation is needed. The function must take one argument, anumpy.ndarrayof the scaledDataType, and return anumpy.ndarrayhaving the same data type as numpyArray.parentCollection (
DatasetCollection, optional) – ParentDatasetCollectionthat this object is part of (if any).queryableAttributes (
tupleofQueryableAttribute, optional) – Queryable attributes defined for this object.queryableAttributeValues (
dictmappingstrtoobject, optional) – Values of the queryable attributes, expressed as a dictionary mapping the case-insensitive names of queryable attributes to their values.lazyPropertyValues (
dictmappingstrtoobject, optional) – Lazy properties to set when this object is constructed, expressed as a dictionary mapping the names of lazy properties to their values.
- Returns:
NumpyGridinstance.- Return type:
Properties
- property Array
None
- 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)intorfloatvalue 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.
Reads an entire
Gridinto a newly-allocated numpy array and wraps it in aNumpyGridinstance.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.