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)
Methods
__init__
(crs, tile_size, resolution[, origin])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
Pixel boundary alignment
List of dimension names of the grid spec
Tile size in pixels in CRS dimension order (Usually y,x or lat,lon)
Attributes:
Pixel boundary alignment
List of dimension names of the grid spec
Tile size in pixels in CRS dimension order (Usually y,x or lat,lon)
Methods:
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.- 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]
- Return type
- property tile_resolution: Tuple[int, int]#
Tile size in pixels in CRS dimension order (Usually y,x or lat,lon)
- tiles(bounds, geobox_cache=None)[source]#
Returns an iterator of tile_index,
GeoBox
tuples across the grid and overlapping with the specified bounds rectangle.Note
Grid cells are referenced by coordinates (x, y), which is the opposite to the usual CRS dimension order.
- tiles_from_geopolygon(geopolygon, tile_buffer=None, geobox_cache=None)[source]#
Returns an iterator of tile_index,
GeoBox
tuples across the grid and overlapping with the specified geopolygon.Note
Grid cells are referenced by coordinates (x, y), which is the opposite to the usual CRS dimension order.
- Parameters
- Return type
- Returns
iterator of grid cells with
GeoBox
tiles