Select to view content in your preferred language

model builder to create NDVI

5369
1
10-06-2014 07:53 AM
DavidAinley1
Emerging Contributor

I need to create an NDVI from multiple NAIP images and I will need to do it 3 or 4 times in the next year or 2.

 

I have all the imagery in a folder which (I think) I will iterate through... but I need to generate an output in order to pull the bands I need into the raster calculator. advice?

 

Thanks,

Hank

0 Kudos
1 Reply
curtvprice
MVP Alum

My advice, first build a model that will work on one raster, then worry about iteration after that.

You may need to use the Calculate Value tool to pull out the paths of the band in the NAIP image. In the example below, I'm assuming you have a model element set up (of type Raster Layer) called "NAIP raster".

Calculate Value parameters:

Expression:

f(r"%NAIP raster%")

Code block:

import os

import arcpy

def f(raster):

  raspath = arcpy.Describe(raster).catalogPath

  return os.path.join(raspath, "Band_1")

Data type:

Raster Dataset

You would need one of these for each band. In ModelBuilder, they should be available for use in the Raster Calculator tool.

If you get this working, you could nest this model inside another one that uses Iterate Rasters to run each raster in the folder in turn.

0 Kudos