Multispectral Imagery Python - NAIP, Landsat, Fire & Remote Sensing


Welcome to Week 7!

Welcome to week 7 of Earth Analytics!

At the end of this week you will be able to:

  • Describe what a spectral band is in remote sensing data.
  • Create maps of spectral remote sensing data using different band combinations including CIR and RGB.
  • Calculate NDVI in Python using.
  • Get NAIP remote sensing data from Earth Explorer.
  • Use the Landsat file naming convention to determine correct band combinations for plotting and calculating NDVI.
  • Define additive color model.

Download Week Cold Springs Fire Data (~150 MB)

Or use earthpy et.data.get_data('cold-springs-fire')

TimeTopicSpeaker
20 minutesReview / questions 
20-30 minutesIntroduction to multispectral remote sensing 
Coding part ICoding Session: Multispectral data in Python using Rasterio 
Coding part IIVegetation indices and NDVI in Python 

1a. Remote Sensing Readings

/Users/lewa8222/anaconda3/envs/earth-analytics-python/lib/python3.6/site-packages/earthpy/spatial.py:372: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  rgb_bands = arr[[rgb]]
Homework plots 1 & 2 RGB and CIR images using NAIP data from 2017.
Homework plots 1 & 2 RGB and CIR images using NAIP data from 2017.

The intermediate NDVI plots below are not required for your homework. They are here so you can compare intermediate outputs if you want to! You will need to create these datasets to process the final NDVI difference plot that is a homework item!

/Users/leah-su/anaconda3/envs/earth-analytics-python/lib/python3.6/site-packages/matplotlib/tight_layout.py:177: UserWarning: The left and right margins cannot be made large enough to accommodate all axes decorations. 
  warnings.warn('The left and right margins cannot be made large '
/Users/leah-su/anaconda3/envs/earth-analytics-python/lib/python3.6/site-packages/matplotlib/tight_layout.py:182: UserWarning: The bottom and top margins cannot be made large enough to accommodate all axes decorations. 
  warnings.warn('The bottom and top margins cannot be made large '
/Users/leah-su/anaconda3/envs/earth-analytics-python/lib/python3.6/site-packages/matplotlib/tight_layout.py:209: UserWarning: tight_layout cannot make axes height small enough to accommodate all axes decorations
  warnings.warn('tight_layout cannot make axes height small enough '
COMPARISON plots - intermediate NDVI NAIP outputs. These plots are just here if you want to compare your intermediate outputs with the instructors.
COMPARISON plots - intermediate NDVI NAIP outputs. These plots are just here if you want to compare your intermediate outputs with the instructors.
Homework plot 3 NDVI difference using NAIP 2017 - NAIP 2015.
Homework plot 3 NDVI difference using NAIP 2017 - NAIP 2015.
---------------------------------------------------------------------------

AttributeError                            Traceback (most recent call last)

<ipython-input-33-e68fbe548849> in <module>()
      6 # Stack landsat tif files using es.stack_raster_tifs - earthpy
      7 
----> 8 landsat_pre, landsat_pre_meta = es.stack_raster_tifs(all_landsat_band_paths, landsat_pre_out)
      9 extent_landsat = plotting_extent(landsat_pre[0], landsat_pre_meta["transform"])


~/anaconda3/envs/earth-analytics-python/lib/python3.6/site-packages/earthpy/spatial.py in stack_raster_tifs(band_paths, out_path)
     80         # save out a stacked gtif file
     81         with rio.open(out_path, 'w', **dest_kwargs) as dest:
---> 82             return stack(sources, dest)
     83 
     84 


~/anaconda3/envs/earth-analytics-python/lib/python3.6/site-packages/earthpy/spatial.py in stack(sources, dest)
    100     #    raise ValueError("The output directory path that you provided does not exist")
    101 
--> 102     if not type(sources[0]) == rio._io.RasterReader:
    103         raise ValueError("The sources object should be of type: rasterio.RasterReader")
    104 


AttributeError: module 'rasterio._io' has no attribute 'RasterReader'

Updated: