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
- pyramid
tilematrix.TilePyramid
output
TilePyramid
- crs
rasterio.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_crs
rasterio.crs.CRS
rasterio CRS object (default: CRS of process pyramid)
- out_crs
- 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
- tile
Tile
- tile
- Returns
- input tile
InputTile
tile view of input data
- input tile
- 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
- tile
Tile
- kwargskeyword arguments
driver specific parameters
- tile
- Attributes
- tiletile
Tile
- input_data
InputData
parent InputData object
- resamplingstring
resampling method passed on to rasterio
- tiletile
- 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_pyramied
TilePyramid
orBufferedTilePyramid
tile pyramid to estimate target tile size
- Returns
- segmenize valuefloat
length suggested of line segmentation to reproject file bounds