Model

Core classes used across modules.

class datacube.model.CellIndex(x, y)
x

Alias for field number 0

y

Alias for field number 1

class datacube.model.Dataset(type_, metadata_doc, local_uri=None, uris=None, sources=None, indexed_by=None, indexed_time=None, archived_time=None)[source]

A Dataset. A container of metadata, and refers typically to a multi-band raster on disk.

Most important parts are the metadata_doc and uri.

Parameters:
  • metadata_doc (dict) – the document (typically a parsed json/yaml)
  • uris (list[str]) – All active uris for the dataset
archived_time = None
Type:datetime.datetime
bounds
Return type:geometry.BoundingBox
center_time
Return type:datetime.datetime
crs
Return type:geometry.CRS
extent
Return type:geometry.Geometry
id
Return type:UUID
indexed_by = None

The User who indexed this dataset :type: str

indexed_time = None
Type:datetime.datetime
is_archived

Is this dataset archived?

(an archived dataset is one that is not intended to be used by users anymore: eg. it has been replaced by another dataset. It will not show up in search results, but still exists in the system via provenance chains or through id lookup.)

Return type:bool
local_path

A path to this dataset on the local filesystem (if available).

Return type:pathlib.Path
local_uri

The latest local file uri, if any. :rtype: str

metadata_doc = None

The document describing the dataset as a dictionary. It is often serialised as YAML on disk or inside a NetCDF file, and as JSON-B inside the database index. :type: dict

sources = None

The datasets that this dataset is derived from (if requested on load). :type: dict[str, Dataset]

type = None
Return type:DatasetType
uris = None

Active URIs in order from newest to oldest

class datacube.model.DatasetType(metadata_type, definition, id_=None)[source]

Product definition

Parameters:
definition = None

product definition document

dimensions

List of dimensions for data in this product

Type:tuple[str]
grid_spec

Grid specification for this product

Return type:GridSpec
id = None
Type:int
lookup_measurements(measurements=None)[source]

Find measurements by name

Parameters:measurements (list[str]) – list of measurement names
Return type:OrderedDict[str,dict]
measurements

Dictionary of measurements in this product

Type:dict[str, dict]
metadata_type = None
Return type:MetadataType
name
Type:str
class datacube.model.GridSpec(crs, tile_size, resolution, origin=None)[source]

Definition for a regular spatial grid

>>> gs = GridSpec(crs=geometry.CRS('EPSG:4326'), tile_size=(1, 1), resolution=(-0.1, 0.1), origin=(-50.05, 139.95))
>>> gs.tile_resolution
(10, 10)
>>> list(gs.tiles(geometry.BoundingBox(140, -50, 141.5, -48.5)))
[((0, 0), GeoBox(10, 10, Affine(0.1, 0.0, 139.95,
       0.0, -0.1, -49.05), EPSG:4326)), ((1, 0), GeoBox(10, 10, Affine(0.1, 0.0, 140.95,
       0.0, -0.1, -49.05), EPSG:4326)), ((0, 1), GeoBox(10, 10, Affine(0.1, 0.0, 139.95,
       0.0, -0.1, -48.05), EPSG:4326)), ((1, 1), GeoBox(10, 10, Affine(0.1, 0.0, 140.95,
       0.0, -0.1, -48.05), EPSG:4326))]
Parameters:
  • crs (geometry.CRS) – Coordinate System used to define the grid
  • tile_size ([float,float]) – (Y, X) size of each tile, in CRS units
  • resolution ([float,float]) – (Y, X) size of each data point in the grid, in CRS units. Y will usually be negative.
  • origin ([float,float]) – (Y, X) coordinates of a corner of the (0,0) tile in CRS units. default is (0.0, 0.0)
alignment

Pixel boundary alignment

Type:(float,float)
crs = None
Return type:geometry.CRS
dimensions

List of dimension names of the grid spec

Type:(str,str)
static grid_range(lower, upper, step)[source]

Returns the indices along a 1D scale.

Used for producing 2D grid indices.

>>> list(GridSpec.grid_range(-4.0, -1.0, 3.0))
[-2, -1]
>>> list(GridSpec.grid_range(1.0, 4.0, -3.0))
[-2, -1]
>>> list(GridSpec.grid_range(-3.0, 0.0, 3.0))
[-1]
>>> list(GridSpec.grid_range(-2.0, 1.0, 3.0))
[-1, 0]
>>> list(GridSpec.grid_range(-1.0, 2.0, 3.0))
[-1, 0]
>>> list(GridSpec.grid_range(0.0, 3.0, 3.0))
[0]
>>> list(GridSpec.grid_range(1.0, 4.0, 3.0))
[0, 1]
origin = None
Type:(float, float)
resolution = None
Type:(float,float)
tile_coords(tile_index)[source]

Tile coordinates in (Y,X) order

Parameters:tile_index ((int,int)) – in X,Y order
Return type:(float,float)
tile_geobox(tile_index)[source]

Tile geobox.

Parameters:tile_index ((int,int)) –
Return type:datacube.utils.geometry.GeoBox
tile_resolution

Tile size in pixels in CRS dimension order (Usually y,x or lat,lon)

Type:(float, float)
tile_size = None
Type:(float,float)
tiles(bounds)[source]

Returns an iterator of tile_index, GeoBox tuples across the grid and inside the specified bounds.

Note

Grid cells are referenced by coordinates (x, y), which is the opposite to the usual CRS dimension order.

Parameters:bounds (BoundingBox) – Boundary coordinates of the required grid
Returns:iterator of grid cells with GeoBox tiles
tiles_inside_geopolygon(geopolygon, tile_buffer=(0, 0))[source]

Returns an iterator of tile_index, GeoBox tuples across the grid and inside the specified polygon.

Note

Grid cells are referenced by coordinates (x, y), which is the opposite to the usual CRS dimension order.

Parameters:
  • geopolygon (geometry.Geometry) – Polygon to tile
  • tile_buffer
Returns:

iterator of grid cells with GeoBox tiles

class datacube.model.MetadataType(definition, dataset_search_fields, id_=None)[source]

Metadata Type definition

dataset_fields = None
Type:dict[str,datacube.index.fields.Field]
definition = None
Type:dict
id = None
Type:int
class datacube.model.Range(begin, end)
begin

Alias for field number 0

end

Alias for field number 1

class datacube.model.Variable(dtype, nodata, dims, units)
dims

Alias for field number 2

dtype

Alias for field number 0

nodata

Alias for field number 1

units

Alias for field number 3