A Quick Lesson in Multi-band Rasters Using NAIP
In this exercise you will explore some visualizations and calculate simple spectral indices using NAIP imagery (see Tip 1). You will also get some more practice performing spatial overlays and merging vectors.
Data and directory structure
First we will need the data. Download the vector file of fire perimeters and the 2022 NAIP image below.
- fire perimeters
- NAIP image (This NAIP file has been clipped and slightly downsampled from 0.6 m resolution to 1 m resolution.)
The fire perimeters data is a subset of polygons from California Historical Fire Perimeters dataset from California Open Data Portal.
The National Agriculture Imagery Program (NAIP) acquires aerial imagery during the agricultural growing seasons in the United States. It is generally made available to governmental agencies and the public within a year of acquisition.
- High-resolution aerial imagery of the continental United States
- Collected during agricultural growing seasons
- Typically 4-band: Red, Green, Blue, Near-Infrared (NIR)
- 60 cm (or better) spatial resolution
- Updated on a 2-3 year cycle for each state
Create a working directory, called lab_10, for this lab in your nr218 folder. Create a data folder and put the downloaded data inside. Then:
- Open QGIS and start a new project
- Change the project CRS to EPSG:6339
- Save it in the
lab_10folder ascoffee_fire.qgz
Also create a text document (using Notepad, TextEdit, gedit, or similar), name it answers.txt, and save it in lab_10. Throughout this lab there will be questions included in the format of the text below. Answer the questions in answers.txt.
Questions will be included in this format, with a sidebar and in grey, throughout the exercise.
You should now have a directory structure like this.
lab_10/
├── coffee_fire.qgz
├── data/
│ ├── subset_of_cal_hist_fires.geojson
│ └── naip_2022.tif
└── answers.txt
Data Preparation
During this workflow, there is no need to save any file with scratch in the name. You will want to save other files in your data directory.
Open
subset_of_cal_hist_fires.geojsonin QGIS.Add a basemap.
Question 1. Where are these fire perimeters?
fires_in_AOI
Question 2. What CRS is
subset_of_cal_hist_fires.geojsonin? Is there something you should do regarding the CRS?
Extract the perimeter of the Coffee Fire (
FIRE_NAMEisCOFFEE). There are a few ways you can do this, your choice. Name the resulting layerCoffee fire. (I would recommend naming the file you savecoffee_fire.geojson.)Reduce the number of polygons in the fire perimeter layer,
subset_of_cal_hist_fires, by selecting only fires that have happened since 2014 (Hint: extract by attribute), i.e.YEAR_ > 2013. Name the resulting layerscratch_1.Use the “Extract layer extent” tool to get a polygon of the extent of the Coffee fire. Name the result
scratch_extent.Buffer
scratch_extentby 1000 m, using mitered joint style. Name the buffered layer, our area of interest,AOI. Figure 1 shows the layers that should have been created at this point (AOI is still calledBufferedin the image).
Question 3. Try buffering
scratch_extentwith the default joint style instead of mitered. What is the difference?
Now extract all of the polygons in
scratch_1which intersectAOI(Hint: “select by location”). Name the resultscratch_2.Clip
scratch_2byAOI. Save the results asfires_in_AOI.When you are satisfied that
fires_in_AOIturned out correctly, you can deletescratch_1,scratch_2, andscratch_extent. (Now you should not have any temporary layers in your layer panel.)
- Open
naip_2022. If you have a basemap on, turn it off so that the NAIP imagery is over a white background. Notice that the image looks very pale. Open the Layer Properties dialog. Go to the Transparency tab on the left (see Figure 2). Change the transparency band to None. See the change that occurs.
Question 4. What just happened when you made that change. What is band 4 in the image? QGIS was interpreting it as a transparency band, why?
Explore Visualizations and Spectral Indices
- Now view the image as False color
- Recall from earlier, that means Near-Infrared to Red, Red to Green, and Green to Blue (i.e. band order is NIR, G, R)
- Open symbology and change the band order
- Zoom in so that individual trees are visible.
- Save your QGIS project so the false-color visualization is preserved.
Question 5. Why do trees stand out from the ground using this false color image?
- Calculate Normalized Difference Vegetation Index (NDVI) using the Raster Calculator. Save the file as
NDVI.tif
\[NDVI = \frac{NIR - Red}{NIR + Red}\]
NDVI Values
| Value Range | Interpretation |
|---|---|
| -1 to 0 | Water, clouds, or non-vegetated surfaces. |
| 0 to 0.1 | Exposed rock, sand, or snow. |
| 0.2 to 0.5 | Sparse vegetation, |
| 0.6 to 0.9 | Dense Vegetation |
Question 6. a) How many bands does the NDVI raster have?
- Adjust the symbology to some color scheme you think is appropriate for displaying NDVI.
The Soil Adjusted Vegetation Index (SAVI) is useful when the soil is highly exposed in an image. Soil is often highly reflective across all bands, reducing the contrast between vegetation and soil. It is the same as NDVI with an adjustment factor, \(L\), to compensate for soil.
\[ SAVI = \frac{(NIR - Red) \times (1 + L)}{NIR + Red + L} \]
- Calculate SAVI. Use similar symbology rules you used for NDVI.
Where \(L\) is often 0.5, but can be adjusted for more reflective exposed soil. The soil in the Klamath Mountains, where this data is from, tends to be highly reflective, which means a fairly high value of \(L\) (close to 1) should be used. Experiment with values of \(L\) to see if you can make a raster where contrast between trees and soil is higher than in your NDVI raster.
Question 7. a) Were you able to improve upon NDVI using SAVI? b) What value of \(L\) did you end up using?
c) NDVI is defined on the interval [-1, -1], what about SAVI?
Finding Zonal Statistics
Extract a separate
River firelayer, for the River Complex, from yourfires in AOIlayer.Spatial Overlays:
- Find the difference between the
River fireandCoffee firelayers, call itriver only, - Find the difference between the
Coffee fireandRiver firelayers, call itcoffee only - Find the intersection between the
Coffee fireandRiver firelayers, call itboth - Use the AOI and the three layers you just found to make a polygon called
unburned, i.e areas burned by neither fire.
- Find the difference between the
Change the value of the
FIRE_NAMEattribute for each of the layers you created in the last step to match the layer name.Use the Merge vector layers tool to merge the four layers you just created (
river only,coffee only,both,unburned). Save the merged layer astreatments.geojson. Change the symbology of the treatments layer to categorized. Removeriver only,coffee only,both, andunburnedlayers.
Question 8. One can think of the layer you just created as containing polygons representing four treatments in a natural experiment. Describe what each of the polygons you created represents.
- Use the zonal statistics tool to find mean, median, and standard deviation of NDVI in each treatment.
Question 9. Paste the mean median and standard distributions from the zonal statistics.
Question 10. Briefly describe the differences in NDVI between the four treatments. Include a table showing the NDVI statistics you calculated (You can export the file as a csv with only the columns you want, and open it in Excel, then paste into your text file).
Question 11. Use
treeand paste output to show the structure of your working directory.
Question 11. Describe how the steps taken here fit into the Filter, Map, Reduce workflow.
Submission
As usual, zip you lab_10 directory and submit to Canvas.
| Part | Items | % of points |
|---|---|---|
| Project Works |
|
20% |
| Data preparation and vector workflow |
|
25% |
| NAIP visualization and spectral-index workflow |
|
20% |
| Spatial overlays and zonal statistics |
|
20% |
answers.txt |
|
15% |