mapchete.formats.default.tile_directory module¶
Use a directory of zoom/row/column tiles as input.
- class mapchete.formats.default.tile_directory.InputData(input_params, **kwargs)¶
Bases:
InputData
Main input class.
- Parameters
- input_paramsdictionary
driver specific parameters
- Attributes
- pathstring
path to Mapchete file
- 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': None, 'driver_name': 'TileDirectory', 'file_extensions': None, '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
- 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.tile_directory.InputTile(tile, data_type=None, basepath=None, file_extension=None, profile=None, td_crs=None, td_pyramid=None, read_as_tiledir_func=None)¶
Bases:
InputTile
Target Tile representation of input data.
- Parameters
- tile
Tile
- kwargskeyword arguments
driver specific parameters
- tile
- Attributes
- tiletile
Tile
- tiletile
- is_empty(tile_directory_zoom=None, fallback_to_higher_zoom=False, matching_method='gdal', matching_precision=8, matching_max_zoom=None)¶
Check if there is data within this tile.
- Parameters
- tile_directory_zoomNone
If set, data will be read from exactly this zoom level
- matching_methodstr (‘gdal’ or ‘min’) (default: ‘gdal’)
- gdal: Uses GDAL’s standard method. Here, the target resolution is calculated
by averaging the extent’s pixel sizes over both x and y axes. This approach returns a zoom level which may not have the best quality but will speed up reading significantly.
- min: Returns the zoom level which matches the minimum resolution of the
extents four corner pixels. This approach returns the zoom level with the best possible quality but with low performance. If the tile extent is outside of the destination pyramid, a TopologicalError will be raised.
- matching_max_zoomint (default: None)
If set, it will prevent reading from zoom levels above the maximum.
- matching_precisionint
Round resolutions to n digits before comparing.
- fallback_to_higher_zoombool (default: False)
In case no data is found at zoom level, try to read data from higher zoom levels. Enabling this setting can lead to many IO requests in areas with no data.
- Returns
- is emptybool
- read(indexes=None, resampling='nearest', tile_directory_zoom=None, matching_method='gdal', matching_max_zoom=None, matching_precision=8, fallback_to_higher_zoom=False, validity_check=False, dst_nodata=None, gdal_opts=None, **kwargs)¶
Read reprojected & resampled input data.
- Parameters
- tile_directory_zoomNone
If set, data will be read from exactly this zoom level
- matching_methodstr (‘gdal’ or ‘min’) (default: ‘gdal’)
- gdal: Uses GDAL’s standard method. Here, the target resolution is calculated
by averaging the extent’s pixel sizes over both x and y axes. This approach returns a zoom level which may not have the best quality but will speed up reading significantly.
- min: Returns the zoom level which matches the minimum resolution of the
extents four corner pixels. This approach returns the zoom level with the best possible quality but with low performance. If the tile extent is outside of the destination pyramid, a TopologicalError will be raised.
- matching_max_zoomint (default: None)
If set, it will prevent reading from zoom levels above the maximum.
- matching_precisionint
Round resolutions to n digits before comparing.
- fallback_to_higher_zoombool (default: False)
In case no data is found at zoom level, try to read data from higher zoom levels. Enabling this setting can lead to many IO requests in areas with no data.
- resamplingstring
raster file: one of “nearest”, “average”, “bilinear” or “lanczos”
- validity_checkbool
vector file: also run checks if reprojected geometry is valid, otherwise throw RuntimeError (default: True)
- 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.
- dst_nodataint or float, optional
raster file: if not set, the nodata value from the source dataset will be used
- gdal_optsdict
raster file: GDAL options passed on to rasterio.Env()
- Returns
- datalist for vector files or numpy array for raster files