rio_tiler.models
rio_tiler.models ¶
rio-tiler models.
ImageData ¶
Image Data class.
Attributes:
-
array(MaskedArray) –image values.
-
assets(list) –list of assets used to construct the data values.
-
bounds(BoundingBox) –bounding box of the data.
-
crs(CRS) –Coordinates Reference System of the bounds.
-
metadata(dict) –Additional metadata. Defaults to
{}. -
band_names(list) –name of each band. Defaults to
["b1", "b2", "b3"]for 3 bands image. -
dataset_statistics(list) –dataset statistics
[(min, max), (min, max)]
Note: mask should be considered as PER_BAND so shape should be similar as the data
_check_alpha_mask ¶
_check_alpha_mask(attribute, value)
Make sure alpha mask has valid shame and datatype.
apply_color_formula ¶
Apply color-operations formula in place.
apply_colormap ¶
apply_colormap(colormap: ColorMapType) -> ImageData
Apply colormap to the image data.
apply_expression ¶
Apply expression to the image data.
create_from_list
classmethod
¶
Create ImageData from a sequence of ImageData objects.
Parameters:
-
data(sequence) –sequence of ImageData.
data_as_image ¶
data_as_image() -> ndarray
Return the data array reshaped into an image processing/visualization software friendly order.
(bands, rows, columns) -> (rows, columns, bands).
get_coverage_array ¶
get_coverage_array(shape: Dict, shape_crs: CRS = WGS84_CRS, cover_scale: int = 10) -> NDArray[floating]
Get Coverage array for a Geometry.
Parameters:
-
shape(Dict) –GeoJSON geometry or Feature.
-
shape_crs(CRS, default:WGS84_CRS) –Coordinates Reference System of shape.
-
cover_scale(int, default:10) –Scale used when generating coverage estimates of each raster cell by vector feature. Coverage is generated by rasterizing the feature at a finer resolution than the raster then using a summation to aggregate to the raster resolution and dividing by the square of cover_scale to get coverage value for each cell. Increasing cover_scale will increase the accuracy of coverage values; three orders magnitude finer resolution (cover_scale=1000) is usually enough to get coverage estimates with <1% error in individual edge cells coverage estimates, though much smaller values (e.g., cover_scale=10) are often sufficient (<10% error) and require less memory.
Returns:
Note: code adapted from perrygeo/python-rasterstats!136 by @sgoodm
post_process ¶
post_process(in_range: Optional[Sequence[IntervalTuple]] = None, out_dtype: Union[str, number] = 'uint8', color_formula: Optional[str] = None, **kwargs: Any) -> ImageData
Post-process image data.
Parameters:
-
in_range(tuple, default:None) –input min/max bounds value to rescale from.
-
out_dtype(str, default:'uint8') –output datatype after rescaling. Defaults to
uint8. -
color_formula(str, default:None) –color-ops formula (see: vincentsarago/color-ops).
-
kwargs(optional, default:{}) –keyword arguments to forward to
rio_tiler.utils.linear_rescale.
Returns:
-
ImageData(ImageData) –new ImageData object with the updated data.
Examples:
>>> img.post_process(in_range=((0, 16000), ))
>>> img.post_process(color_formula="Gamma RGB 4.1")
render ¶
render(add_mask: bool = True, img_format: str = 'PNG', colormap: Optional[ColorMapType] = None, **kwargs) -> bytes
Render data to image blob.
Parameters:
-
add_mask(bool, default:True) –add mask to output image. Defaults to
True. -
img_format(str, default:'PNG') –output image format. Defaults to
PNG. -
colormap(dict or sequence, default:None) –RGBA Color Table dictionary or sequence.
-
kwargs(optional, default:{}) –keyword arguments to forward to
rio_tiler.utils.render.
Returns:
-
bytes(bytes) –image.
reproject ¶
reproject(dst_crs: CRS, resolution: Optional[Tuple[float, float]] = None, reproject_method: WarpResampling = 'nearest') -> ImageData
Reproject data and mask.
rescale ¶
rescale(in_range: Sequence[IntervalTuple], out_range: Sequence[IntervalTuple] = ((0, 255),), out_dtype: Union[str, number] = 'uint8') -> Self
Rescale data in place.
resize ¶
Resize data and mask.
PointData ¶
Point Data class.
Attributes:
-
array(MaskedArray) –pixel values.
-
band_names(list) –name of each band. Defaults to
["1", "2", "3"]for 3 bands image. -
coordinates(tuple) –Point's coordinates.
-
crs(CRS) –Coordinates Reference System of the bounds.
-
assets(list) –list of assets used to construct the data values.
-
metadata(dict) –Additional metadata. Defaults to
{}.
apply_expression ¶
Apply expression to the image data.
rescale_image ¶
rescale_image(array: MaskedArray, in_range: Sequence[IntervalTuple], out_range: Sequence[IntervalTuple] = ((0, 255),), out_dtype: Union[str, number] = 'uint8') -> MaskedArray
Rescale image data in-place.