def test_from_authority__ignf(): cc = CRS.from_authority("IGNF", "ETRS89UTM28") assert cc.to_authority() == ("IGNF", "ETRS89UTM28") if parse_version(proj_version_str) > parse_version("6.1.0"): assert cc.to_authority("EPSG") == ("EPSG", "25828") assert cc.to_epsg() == 25828 else: assert cc.to_epsg() is None
def test_nonearthbody(): """COGReader should work with non-earth dataset.""" with pytest.warns(UserWarning): with COGReader(COG_EUROPA) as cog: assert cog.minzoom == 0 assert cog.maxzoom == 24 with pytest.warns(None) as warnings: with COGReader(COG_EUROPA) as cog: assert cog.info() assert len(warnings) == 2 img = cog.read() assert numpy.array_equal(img.data, cog.dataset.read(indexes=(1, ))) assert img.width == cog.dataset.width assert img.height == cog.dataset.height assert img.count == cog.dataset.count img = cog.preview() assert img.bounds == cog.bounds part = cog.part(cog.bounds, bounds_crs=cog.crs) assert part.bounds == cog.bounds lon = (cog.bounds[0] + cog.bounds[2]) / 2 lat = (cog.bounds[1] + cog.bounds[3]) / 2 assert cog.point(lon, lat, coord_crs=cog.crs)[0] is not None europa_crs = CRS.from_authority("ESRI", 104915) tms = TileMatrixSet.custom( crs=europa_crs, extent=europa_crs.area_of_use.bounds, matrix_scale=[2, 1], ) with pytest.warns(None) as warnings: with COGReader(COG_EUROPA, tms=tms) as cog: assert cog.minzoom == 4 assert cog.maxzoom == 6 # Get Tile covering the UL corner bounds = transform_bounds(cog.crs, tms.rasterio_crs, *cog.bounds) t = tms._tile(bounds[0], bounds[1], cog.minzoom) img = cog.tile(t.x, t.y, t.z) assert img.height == 256 assert img.width == 256 assert img.crs == tms.rasterio_crs assert len(warnings) == 0
def test_ignf_authority_repr(): assert repr(CRS.from_authority( "IGNF", "ETRS89UTM28")).startswith("<Projected CRS: IGNF:ETRS89UTM28>")
def test_from_authority__ignf(): cc = CRS.from_authority("IGNF", "ETRS89UTM28") assert cc.to_authority() == ("IGNF", "ETRS89UTM28") assert cc.to_authority("EPSG") == ("EPSG", "25828") assert cc.to_epsg() == 25828
from typing import List, Tuple from shapely.geometry import box, mapping, Polygon from geoalchemy2.shape import to_shape, WKBElement from pyproj import Transformer, CRS WGS_TO_MOLLWEIDE = Transformer.from_crs(CRS.from_authority('EPSG', 4326), CRS.from_authority('ESRI', 54009), always_xy=True).transform def bbox_to_wkt(bbox): """ Convert a bbox to WKT. :param List[float] bbox: the bbox as a list of floats in [minx, miny, maxx, maxy]. :returns: WKT representation :rtype: str """ return box(*bbox).wkt def bbox_to_geom(bbox): """ Convert a bbox to a shapely geometry. :param List[float] bbox: the bbox as a list of floats in [minx, miny, maxx, maxy]. :returns: shapely Polygon :rtype: Polygon