{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Spatial Operations and `rio`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Today we are going to use the spatial background we learned yesterday and apply it to dataset exploration of an AVIRIS image. We are going to use the `rio` module of `xarray`." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "# Libraries for image visualization\n", "from IPython.display import Image\n", "from IPython.core.display import HTML " ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import xarray as xr" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First let's open the datafile. We are going to use the argument `engine='rasterio'` because we are using an ENVI file type. This is also the recommended method for opening TIF files." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "aviris_ds = xr.open_dataset('./data/subset_f131205t01p00r10rdn_e_sc01_ort_img', engine='rasterio')" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "# Extract just the band DataArray from the dataset\n", "aviris = aviris_ds['band_data']" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.DataArray 'band_data' (band: 224, y: 300, x: 100)>\n", "[6720000 values with dtype=float32]\n", "Coordinates:\n", " * band (band) int64 1 2 3 4 5 6 7 8 ... 218 219 220 221 222 223 224\n", " xc (y, x) float64 5.777e+05 5.777e+05 ... 5.814e+05 5.814e+05\n", " yc (y, x) float64 4.151e+06 4.151e+06 ... 4.148e+06 4.148e+06\n", " spatial_ref int64 0\n", "Dimensions without coordinates: y, x\n", "Attributes:\n", " long_name: ('Band 1', 'Band 2', 'Band 3', 'Band 4', 'Band...\n", " bands: 224\n", " band_names: Band 1,Band 2,Band 3,Band 4,Band 5,Band 6,Band...\n", " byte_order: 0\n", " coordinate_system_string: PROJCS["unnamed",GEOGCS["GCS_WGS_1984",DATUM["...\n", " data_type: 2\n", " description: ./output_data/subset_f131205t01p00r10rdn_e_sc0...\n", " file_type: ENVI Standard\n", " header_offset: 0\n", " interleave: bsq\n", " lines: 300\n", " samples: 100