SingleFileBackend

class bruty.world_raster_database.SingleFileBackend(epsg, x1, y1, x2, y2, history_class, storage_class, data_class, data_path)

Bases: bruty.world_raster_database.WorldTilesBackend

Inheritance diagram of SingleFileBackend

Attributes Summary

epsg

rtype

int

id

Methods Summary

append_accumulation_db(accumulation_db)

get_crs()

get_tile_history(x, y)

get_tile_history_by_index(tx, ty)

get_tiles_index_matrix(x, y, x2, y2)

Get the indices of tiles that fall within rectangle specified by x,y to x2,y2 as a pair of numpy arrays.

get_tiles_index_sparse(x, y, x2, y2)

Get the indices of tiles that fall within rectangle specified by x,y to x2,y2 as a sparse list.

get_tiles_indices(x, y, x2, y2)

Get the indices of tiles that fall within rectangle specified by x,y to x2,y2 as a numpy array of tuples.

iter_tiles(x, y, x2, y2)

iterate_filled_tiles()

make_accumulation_db(data_path)

Make a database that has the same layout and types, probably a temporary copy while computing tiles.

str_to_tile_index(strx, stry)

Inverses the tile_index_to_str naming

tile_index_to_str(tx, ty)

A function that can be overridden to change how directories are created.

Attributes Documentation

epsg
Return type

int

id

Methods Documentation

append_accumulation_db(accumulation_db)
get_crs()
get_tile_history(x, y)
get_tile_history_by_index(tx, ty)
get_tiles_index_matrix(x, y, x2, y2)

Get the indices of tiles that fall within rectangle specified by x,y to x2,y2 as a pair of numpy arrays. Each entry of the returned array is the tx,ty index for a tile. Note that Tile indices are x -> tx which means it is essentially (column, row).

e.g. if the tiles being returned were from tx = 1,2 and ty = 3,4 then the returned value would be (array([[1, 2], [1, 2]]) , array([[3, 3], [4, 4]]))

Parameters
  • x

  • y

  • x2

  • y2

Returns

Return type

Tile X and Tile Y numpy arrays of shape (n, m)

get_tiles_index_sparse(x, y, x2, y2)

Get the indices of tiles that fall within rectangle specified by x,y to x2,y2 as a sparse list. Each entry of the returned list is the tx or ty index for a tile. Note that Tile indices are x -> tx which means it is essentially (column, row).

e.g. if the tiles being returned were from tx = 1,2 and ty = 3,4 then the returned value would be [1,2], [3,4]

Parameters
  • x

  • y

  • x2

  • y2

Returns

Return type

List for tile x of length n and list for tile y of length m

get_tiles_indices(x, y, x2, y2)

Get the indices of tiles that fall within rectangle specified by x,y to x2,y2 as a numpy array of tuples. Each entry of the returned array is the tx,ty index for a tile. Note that Tile indices are x -> tx which means it is essentially (column, row).

e.g. if the tiles being returned were from tx = 1,2 and ty = 3,4 then the returned value would be array([[1, 3], [2, 3], [1, 4], [2, 4]])

Parameters
  • x

  • y

  • x2

  • y2

Returns

Return type

numpy array of shape (n,2)

iter_tiles(x, y, x2, y2)
iterate_filled_tiles()
make_accumulation_db(data_path)

Make a database that has the same layout and types, probably a temporary copy while computing tiles.

Parameters

data_path – Place to store the data. A local temporary directory or subdirectory inside of this directory would make sense if deleted later

Returns

Return type

WorldTilesBackend instance

str_to_tile_index(strx, stry)

Inverses the tile_index_to_str naming

tile_index_to_str(tx, ty)

A function that can be overridden to change how directories are created. The default is just to return the index as a string. An overridden version could add north/south or special named (like 2359, 4999 in TMS_mercator is Atlantic_Marine_Center).

Parameters
  • tx – tile index in x direction

  • ty – tile index in y direction

Returns

Return type

(str, str) of the x and y strings respectively.

__init__(epsg, x1, y1, x2, y2, history_class, storage_class, data_class, data_path)
Parameters
  • tile_scheme – an instance of a TilingScheme derived class which defines what the coordinate to tile index will be

  • history_class – A History derived class that will store the data like a mini-repo based on the tile scheme supplied - probably a RasterHistory

  • storage_class – The data storage for the history_class to use. Probably a MemoryHistory or DiskHistory

  • data_class – Defines how to store the data, probably derived from raster_data.Storage, like TiffStorage or MemoryStorage or BagStorage

  • data_path – Root directory to store file structure under, if applicable.