Пример #1
0
def test_empty_from_roi_respects_footprint():
    # See https://github.com/satellogic/telluric/issues/39
    raster = GeoRaster2.open("tests/data/raster/overlap1.tif")

    empty = GeoRaster2.empty_from_roi(shape=raster.shape[1:][::-1], ul_corner=(v[0] for v in raster.corner('ul').xy),
                                      resolution=raster.res_xy(), crs=raster.crs,
                                      band_names=raster.band_names, dtype=raster.dtype)

    empty_simple = GeoRaster2.empty_from_roi(roi=raster.footprint(),
                                             resolution=raster.res_xy(),
                                             band_names=raster.band_names, dtype=raster.dtype)

    assert raster.footprint().almost_equals(empty.footprint())
    assert raster.footprint().almost_equals(empty_simple.footprint())
Пример #2
0
def test_empty_raster_from_roi_affine_3_bands_high():
    affine = Affine.translation(10, 12) * Affine.scale(2, -2)
    raster = make_test_raster(88, [1, 3, 2], affine=affine, height=1301, width=4)
    empty = GeoRaster2.empty_from_roi(band_names=raster.band_names, roi=raster.footprint(), resolution=2)
    assert(affine.almost_equals(empty.affine))
    assert(raster.crs == empty.crs)
    assert(raster.shape == empty.shape)
Пример #3
0
def test_georaster_contains_geometry():
    roi = GeoVector(Polygon.from_bounds(12.36, 42.05, 12.43, 42.10),
                    WGS84_CRS).reproject(WEB_MERCATOR_CRS)
    resolution = 20.0

    empty = GeoRaster2.empty_from_roi(roi, resolution)

    assert roi in empty
    assert roi.buffer(-1) in empty
    assert roi.buffer(1) not in empty
Пример #4
0
def test_empty_from_roi():
    roi = GeoVector(Polygon.from_bounds(12.36, 42.05, 12.43, 42.10),
                    WGS84_CRS).reproject(WEB_MERCATOR_CRS)
    resolution = 20.0
    band_names = ["a", "b", "c"]
    some_dtype = np.uint16

    empty = GeoRaster2.empty_from_roi(roi, resolution, band_names, some_dtype)

    # Cannot compare approximate equality of polygons because the
    # topology might be different, see https://github.com/Toblerity/Shapely/issues/535
    # (Getting the envelope seems to fix the problem)
    # Also, reprojecting the empty footprint to WGS84 permits using
    # a positive number of decimals (the relative error is of course
    # the same)
    assert empty.footprint().reproject(WGS84_CRS).envelope.almost_equals(
        roi.envelope, decimal=3)
    assert empty.resolution() == resolution
    assert empty.crs == roi.crs
    assert empty.band_names == band_names
    assert empty.dtype == some_dtype
    assert empty.affine.determinant == -1 * resolution * resolution