Hexagon Geospatial
MENU

ERDAS IMAGINE

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 
Reply
Frequent Contributor
Posts: 99
Registered: ‎04-03-2017
Accepted Solution

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.

 

Regards,

 

Josh

Staff
Posts: 118
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
Frequent Contributor
Posts: 99
Registered: ‎04-03-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=',',
							quoting=csv.QUOTE_MINIMAL)
			
		#num_lines = sum(1 for line in open('//gissrv/lidar/Erdas Tree Canopy Work/Tree_Sample_Coords.csv'))	
		
		#for c, row in enumerate(reader):
			#print(c,row[0:2])		
			
		#https://www.alexkras.com/how-to-read-csv-file-in-python/
		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,

 

Josh

 

Technical Evangelist
Posts: 698
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.

 

Cheers

 

Ian Anderson
Chief Product Owner, Desktop Remote Sensing
Hexagon Geospatial
Frequent Contributor
Posts: 99
Registered: ‎04-03-2017

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

I have this machine learning working great for the image that corresponds to the sample points I used.

I tried running the spatial model in a batch across multiple townships but it looks like only the township associated with the shapefile of points works correctly. The other outputs give everything the one category.

 

As we have 40 townships does this mean I need to create sample points for every town? I Assumed it could use the sample points from one shapefile and use this for all images.

 

Thanks,

 

Josh

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

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

Hi Josh,

 

If you have created a trained Machine Intellect based on the training data you should be able to use that Machine Intellect to classify other images / sets of data (assuming the new data has similar characteristics to the data you trained on, as well as the same attributes).

 

Cheers

 

Ian Anderson
Chief Product Owner, Desktop Remote Sensing
Hexagon Geospatial
Frequent Contributor
Posts: 99
Registered: ‎04-03-2017

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

Thanks Ian,

 

There must be something in my spatial model that is stopping it from working properly.

 

The shp with the sample points from Baxter township and the image are input into the Raster Statitics per Feature, then Select Attributes (to get the Tree category)>Initialize Random Forest>Machine Intellect Output>Machine Intellect Input>Classify Using Machine Learning>Raster Output etc.

It's the raster output that is coming up with just the one category over the entire area, apart from the original Baxter township image that the shp was based on. This one works fine.


Regards,


Josh

Highlighted
Frequent Contributor
Posts: 99
Registered: ‎04-03-2017

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

On further testing it looks like the Machine Intellect Output doesn't fail with the other township but it doesn't seem to actually run and freezes when I cancel it. So the fact that the shp and image are in different locations must be causing the issue.

Regular Contributor
Posts: 212
Registered: ‎11-16-2015

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

Hiya,

 

Your model for the other townships should look like this:

2018-12-19 11_54_46-Machine Learning_ Raster Classification - Hexagon Geospatial Community.png

That way you're using the machine intelect that you've saved from the original township and using it on the others. Is that what you're doing?

 

Cheers,

 

Johnnie

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

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

I second Johnnie's comment above. The classification of the other townships should not include all the stuff you did in the original model to train the Machine Intellect (other than whatever you need to do to generate the statistical values you used). It should just use the Machine Intellect file you produced previously.

 

But I'm also curious about this comment "Select Attributes (to get the Tree category)". Are you training / classifying just a single class? Machine Learning generally doesn't work that way (unlike Deep Learning). You need to train at least two classes, e.g. "Tree" and "Not Tree". And usually you would have multiple classes. This is because Machine Learning techniques like Random Forest are trying to discriminate one class from another, not just "extract a class". Just want to make sure you're training on multiple class types.

 

Cheers

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.