Exemplo n.º 1
0
def test_rgb_single_channels():
    """ Check assumptions about single channel R, G, and B images. """
    fnames = [path_to_example(f) for f in ["red.tif", "green.tif", "blue.tif"]]
    rgb_parts = list()
    for f in fnames:
        with rio.open(f) as src:
            rgb_parts.append(src.read())
            assert str(src.crs) == rio.crs.CRS.from_epsg(4326)

    with rio.open(path_to_example("rmnp-rgb.tif")) as src:
        assert np.array_equal(src.read(), np.concatenate(rgb_parts))
Exemplo n.º 2
0
def test_rgb():
    """ Check assumptions about rgb satellite imagery over RMNP. """
    with rio.open(path_to_example("rmnp-rgb.tif")) as src:
        rgb = src.read()
        rgb_crs = src.crs
    assert rgb.shape == (3, 373, 485)
    assert str(rgb_crs) == rio.crs.CRS.from_epsg(4326)
Exemplo n.º 3
0
import earthpy.io as eio
import rasterio as rio

with rio.open(eio.path_to_example('rmnp-dem.tif')) as src:
    dem = src.read()
Exemplo n.º 4
0
def rgb_image():
    """Fixture holding an RGB image for plotting"""
    with rio.open(path_to_example("rmnp-rgb.tif")) as src:
        rgb = src.read()
        ext = plotting_extent(src)
    return rgb, ext
Exemplo n.º 5
0
def test_continental_divide_trail():
    """ Check assumptions about Continental Divide Trail path. """
    cdt = gpd.read_file(path_to_example("continental-div-trail.geojson"))
    assert cdt.shape == (1, 2)
    assert cdt.crs == {"init": "epsg:4326"}
Exemplo n.º 6
0
def test_colorado_glaciers():
    """ Check assumptions about glacier point locations. """
    glaciers = gpd.read_file(path_to_example("colorado-glaciers.geojson"))
    assert glaciers.shape == (134, 2)
    assert glaciers.crs == {"init": "epsg:4326"}
Exemplo n.º 7
0
def test_colorado_counties():
    """ Check assumptions about county polygons. """
    counties = gpd.read_file(path_to_example("colorado-counties.geojson"))
    assert counties.shape == (64, 13)
    assert counties.crs == {"init": "epsg:4326"}
Exemplo n.º 8
0
def test_valid_datasets_get_returned():
    """ If users give a valid dataset name, return a valid path. """
    epsg_path = path_to_example("epsg.json")
    assert os.path.isfile(epsg_path)
Exemplo n.º 9
0
def test_missing_datasets_raise_errors():
    """ Raise errors when users forget to provide a dataset. """
    with pytest.raises(KeyError):
        path_to_example("")
Exemplo n.º 10
0
def test_invalid_datasets_raise_errors():
    """ Raise errors when users provide nonexistent datasets. """
    with pytest.raises(KeyError):
        path_to_example("Non-existent dataset")
Exemplo n.º 11
0
def test_crs_check_bad_file():
    with pytest.raises(rio.errors.RasterioIOError, match="Oops, your data ar"):
        es.crs_check(path_to_example("rmnp.shp"))
Exemplo n.º 12
0
def test_crs_check_tif():
    """Test crs check works properly."""
    crs = es.crs_check(path_to_example("rmnp-rgb.tif"))
    assert (crs.to_epsg() == 4326)