Beispiel #1
0
def test_no_squeeze_band(shared_datadir):
    f = Path(shared_datadir) / TEST_FILE
    g = GeoTiff(f)
    assert g.da.band.size == 3
Beispiel #2
0
"""An example of using the GeoTiff data component.

The example is adapted from http://xarray.pydata.org/en/stable/examples/visualization_gallery.html#imshow()-and-rasterio-map-projections,
and it uses the sample GeoTIFF image "RGB.byte.tif" from the rasterio project.
"""
import cartopy.crs as ccrs
import matplotlib.pyplot as plt

from bmi_geotiff import GeoTiff

tif_file = "RGB.byte.tif"

g = GeoTiff(tif_file)
print(g.da)

crs = ccrs.UTM("18N")
ax = plt.subplot(projection=crs)
g.da.plot.imshow(ax=ax, rgb="band", transform=crs)
plt.show()
Beispiel #3
0
def test_open(shared_datadir):
    g = GeoTiff()
    f = Path(shared_datadir) / TEST_FILE
    g.open(f)
    assert g.filename == f
    assert isinstance(g.da, DataArray)
Beispiel #4
0
def test_squeeze_band():
    g = GeoTiff(TEST_URL)
    assert g.da.ndim != 3
Beispiel #5
0
def test_with_filename_as_url():
    g = GeoTiff(TEST_URL)
    assert isinstance(g, GeoTiff)
    assert g.filename == TEST_URL
    assert isinstance(g.da, DataArray)
Beispiel #6
0
def test_with_filename_as_keyword(shared_datadir):
    f = Path(shared_datadir) / TEST_FILE
    g = GeoTiff(filename=f)
    assert isinstance(g, GeoTiff)
    assert g.filename == f
    assert isinstance(g.da, DataArray)
Beispiel #7
0
def test_bad_filename(tmpdir, shared_datadir):
    with pytest.raises(RasterioIOError):
        GeoTiff("foo.tif")
Beispiel #8
0
def test_instantiate_without_filename():
    g = GeoTiff()
    assert isinstance(g, GeoTiff)
    assert g.filename is None
    assert g.da is None
Beispiel #9
0
"""An example of using the GeoTiff data component.

The data used are band 1 of Landsat 7 ETM scene LE71030642021102ASA00.
"""
import matplotlib.pyplot as plt

from bmi_geotiff import GeoTiff

url = "https://csdms.colorado.edu/data/LE07_L1GT_103064_20210412_20210412_02_RT_B1.TIF"

g = GeoTiff()
g.open(url)
print(g.da)

g.da.plot.imshow()
plt.show()