mapchete.formats.default.raster_file module

Raster file input which can be read by rasterio.

Currently limited by extensions .tif, .vrt., .png and .jp2 but could be extended easily.

class mapchete.formats.default.raster_file.InputData(input_params, **kwargs)

Bases: InputData

Main input class.

Parameters
input_paramsdictionary

driver specific parameters

Attributes
pathstring

path to input file

profiledictionary

rasterio metadata dictionary

pixelbufferinteger

buffer around output tiles

pyramidtilematrix.TilePyramid

output TilePyramid

crsrasterio.crs.CRS

object describing the process coordinate reference system

sridstring

spatial reference ID of CRS (e.g. “{‘init’: ‘epsg:4326’}”)

METADATA = {'data_type': 'raster', 'driver_name': 'raster_file', 'file_extensions': ['tif', 'vrt', 'png', 'jp2'], 'mode': 'r'}
bbox(out_crs=None)

Return data bounding box.

Parameters
out_crsrasterio.crs.CRS

rasterio CRS object (default: CRS of process pyramid)

Returns
bounding boxgeometry

Shapely geometry object

cleanup()

Cleanup when mapchete closes.

exists()

Check if data or file even exists.

Returns
file existsbool
open(tile, **kwargs)

Return InputTile object.

Parameters
tileTile
Returns
input tileInputTile

tile view of input data

class mapchete.formats.default.raster_file.InputTile(tile, input_data, in_memory_raster=None, cache_task_key=None, **kwargs)

Bases: InputTile

Target Tile representation of input data.

Parameters
tileTile
kwargskeyword arguments

driver specific parameters

Attributes
tiletileTile
input_dataInputData

parent InputData object

resamplingstring

resampling method passed on to rasterio

is_empty(indexes=None)

Check if there is data within this tile.

Returns
is emptybool
read(indexes=None, resampling='nearest', **kwargs)

Read reprojected & resampled input data.

Parameters
indexeslist or int

Either a list of band indexes or a single band index. If only a single band index is given, the function returns a 2D array, otherwise a 3D array.

resamplingstr

Resampling method to be used.

Returns
dataarray
mapchete.formats.default.raster_file.get_segmentize_value(input_file=None, tile_pyramid=None)

Return the recommended segmentation value in input file units.

It is calculated by multiplyling raster pixel size with tile shape in pixels.

Parameters
input_filestr

location of a file readable by rasterio

tile_pyramiedTilePyramid or BufferedTilePyramid

tile pyramid to estimate target tile size

Returns
segmenize valuefloat

length suggested of line segmentation to reproject file bounds