def test_aligned_with_internaltile(): """Check if COG is in WebMercator and aligned with internal tiles.""" bounds = WEB_MERCATOR_TMS.bounds(43, 25, 7) with rasterio.open(COG_DST) as src_dst: assert not utils._requested_tile_aligned_with_internal_tile( src_dst, bounds, 256, 256) with rasterio.open(NOCOG) as src_dst: assert not utils._requested_tile_aligned_with_internal_tile( src_dst, bounds, 256, 256) bounds = WEB_MERCATOR_TMS.bounds(147, 182, 9) with rasterio.open(COG_NOWEB) as src_dst: assert not utils._requested_tile_aligned_with_internal_tile( src_dst, bounds, 256, 256) with rasterio.open(COG_WEB_TILED) as src_dst: assert utils._requested_tile_aligned_with_internal_tile( src_dst, bounds, 256, 256)
def test_metadata(): """Should return correct metadata.""" with rasterio.open(COG_CMAP) as src_dst: meta = reader.metadata(src_dst) assert meta["dtype"] == "int8" assert meta["colorinterp"] == ["palette"] assert not meta.get("scale") assert not meta.get("ofsset") assert meta.get("colormap") with rasterio.open(COG_SCALE) as src_dst: meta = reader.metadata(src_dst) assert meta["dtype"] == "int16" assert meta["colorinterp"] == ["gray"] assert meta["scale"] == 0.0001 assert meta["offset"] == 1000.0 assert meta["band_descriptions"] == [("1", "Green")] assert not meta.get("colormap") assert meta["nodata_type"] == "Nodata" meta = reader.metadata(src_dst, indexes=1) assert meta["colorinterp"] == ["gray"] bounds = WEB_MERCATOR_TMS.bounds(218, 99, 8) meta = reader.metadata(src_dst, bounds) assert meta["colorinterp"] == ["gray"] assert meta["bounds"] == bounds with rasterio.open(S3_ALPHA_PATH) as src_dst: with pytest.warns(AlphaBandWarning): meta = reader.metadata(src_dst) assert len(meta["band_descriptions"]) == 3 assert meta["colorinterp"] == ["red", "green", "blue"] assert meta["nodata_type"] == "Alpha" meta = reader.metadata(src_dst, indexes=(1, 2, 3, 4)) assert len(meta["band_descriptions"]) == 4 assert meta["colorinterp"] == ["red", "green", "blue", "alpha"] assert meta["nodata_type"] == "Alpha" with rasterio.open(S3_MASK_PATH) as src_dst: meta = reader.metadata(src_dst) assert meta["nodata_type"] == "Mask"