11-04-2018 03:07 PM - edited 11-04-2018 03:08 PM
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.
Solved! Go to Solution.
11-05-2018 03:30 AM
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...
11-12-2018 04:24 PM
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]) #X value #print(data[input]) #Y value X = data[input] Y = data[input]
11-13-2018 06:54 AM
As an alternative you could try the new Add Attributes by Location operator.
12-17-2018 06:46 PM
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.
12-18-2018 05:32 AM
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).
a month ago
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.
a month ago
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.
a month ago
Your model for the other townships should look like this:
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?
a month ago
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.