Hexagon Geospatial


Discuss and share topics of interest using ERDAS IMAGINE the world’s leading geospatial data authoring system.
Showing results for 
Search instead for 
Do you mean 
Posts: 65
Registered: ‎04-02-2017

How to Exclude Healthy Grass/Shadows from Vegetation Index

[ Edited ]

HI there,


I have a spatial model which extracts the vegetation class from the NIR imagery.

I aim to run this every five years to detect the changes in our shire.

This years imagery was easy. I just used an Input of >= 0.155 and that seemed good enough.

I am having trouble with the 2012 NIR imagery, which has a lot more greener (redder) grass, so I am having trouble getting the right balance so that grass and shadows are excluded and as many trees are included. I have used a range, currently set to >= 0.45 and <= 0.6, but it will either remove too much tree coverage and/or keep too many shadows/grassed areas.


Is there a solution to this? I've attached the spatial model.





Posts: 108
Registered: ‎07-04-2016

Re: How to Exclude Healthy Grass/Shadows from Vegetation Index

Hi Josh,


You can experiment with the Machine Learning operators to classify the raster. One of the possible examples is here https://community.hexagongeospatial.com/t5/ERDAS-IMAGINE/Machine-Learning-Raster-Classification/ta-p...

Kind Regards,
Marina Vardovska
Hexagon Geospatial Support
Posts: 65
Registered: ‎04-02-2017

Re: How to Exclude Healthy Grass/Shadows from Vegetation Index

Thanks Marina,


I am looking at this now.


I have created a shp file with points to pick up grass and trees, and have output an xls file with the X and Y's of these points.

I am writing a Python script to extract these coordinates and pass to the Get Pixel Value function.

An Int Input will pass a row value to the Python script, which I will run via a Spatial Model in a batch going through each row of the xls file.


How can I pass the X and Y from the Python script to the X and Y for the Get Pixel Value function?


Here is my script, which doesn't produce any errors until I get to the Get Pixel value function. I clearly haven't figured out how to pass Python variables to other Spatial Model functions.



import os
import csv
import collections

def iteratecsv(input):
	#with open("//gissrv/lidar/Erdas Tree Canopy Work/Tree_Sample_Coords.csv", "rt") as File:	
	with open("L:\Erdas Tree Canopy Work\Tree_Sample_Coords.csv", "rt") as File:	
		reader = csv.reader(File, delimiter=',', quotechar=',',
		#num_lines = sum(1 for line in open('//gissrv/lidar/Erdas Tree Canopy Work/Tree_Sample_Coords.csv'))	
		#for c, row in enumerate(reader):
		next(reader) #skip header
		data = [r for r in reader]
		#print(data[input][1])	#X value	
		#print(data[input][2])	#Y value
		X = data[input][1]
		Y = data[input][2]

Thanks again,




Technical Evangelist
Posts: 508
Registered: ‎10-01-2015

Re: How to Exclude Healthy Grass/Shadows from Vegetation Index

Hi Josh,


As an alternative you could try the new Add Attributes by Location operator.




Ian Anderson
Chief Product Owner, Desktop Remote Sensing
Hexagon Geospatial
Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.