01-21-2021 12:44 PM
Hi Everyone,
I'm looking for advice on the syntax to convert Erdas Imagine tools into Python code. I've seen the 2020 Erdas Example Scripts but I'm still lost.
As an example I'm trying to convert the Unsupervised Classification tool into Python code.
The required inputs are:
Two things:
If there's anything I said that was confusing or incorrect I would be happy to re-clarify, just trying to figure out how the syntax is setup for Erdas Tools.
Thanks,
Mase
Solved! Go to Solution.
01-22-2021 08:15 AM
I attempted to call the property names like such:
Unsup = m.UnsupervisedClassification(InputFile=inp, OutputClusterLayerFileIn=Class_Band8,
NumberofClasses='10', ClassifyZeros=True, MethodType='K Means') m.Execute()
However, it came back with a RuntimeError: unidentifiable C++ exception and if I try to use m.Preview(Unsup), it comes up with a: 'erdas::sb_ExecutableLibrary:XMLRExecutableOperator:ostRun Failed'. Not a lot to go off of for error checking.
01-22-2021 10:09 AM - edited 01-22-2021 10:10 AM
I was able to figure it out!
I tried to replicate this process with other tools but couldn't get it.
Steps:
The correct code would then be:
Unsup = m.UnsupervisedClassification(InputFile=inp, OutputClusterLayerFileIn=Class_Band8, NumberofClasses='10', ClassifyZeros=1, MethodType='kmeans') m.Execute()
The InputFile is just a '.tif' and the OutputClusterLayerFileIn is the output '.tif'.