datacube.model.GridSpec

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)

__init__(crs, tile_size, resolution, origin=None)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(crs, tile_size, resolution[, origin])

Initialize self.

grid_range(lower, upper, step)

Returns the indices along a 1D scale.

tile_coords(tile_index)

Coordinate of the top-left corner of the tile in (Y,X) order

tile_geobox(tile_index)

Tile geobox.

tiles(bounds[, geobox_cache])

Returns an iterator of tile_index, GeoBox tuples across the grid and overlapping with the specified bounds rectangle.

tiles_from_geopolygon(geopolygon[, …])

Returns an iterator of tile_index, GeoBox tuples across the grid and overlapping with the specified geopolygon.

Attributes

alignment

Pixel boundary alignment

dimensions

List of dimension names of the grid spec

tile_resolution

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