Spatial Modeler Discussions

Gain, exchange, and share knowledge, or discuss topics with other Hexagon Geospatial Product pioneers and experts to get the most out of Hexagon Geospatial products.
Showing results for 
Search instead for 
Do you mean 
Reply
Occasional Contributor
Posts: 5
Registered: ‎11-10-2015

Error running spatial model via Python

I am trying to load a .gmdx model via the modeler.Solution.Load() method and receiving this error:

 

***ERROR NUMBER 676 IN FUNCTION erdas::sb_spatialmodel:Smiley Frustratedolution::Load*

 

Is there any documentation as to what this error means?

 

Thanks.

Technical Evangelist
Posts: 59
Registered: ‎09-16-2015

Re: Error running spatial model via Python

This error indicates that the text in the .gmdx file is not valid XML or the XML is not parsable.  Can you open the file in the Spatial Model Editor?

Occasional Contributor
Posts: 5
Registered: ‎11-10-2015

Re: Error running spatial model via Python

[ Edited ]

I can. A colleague sent it to me after running it on his machine. We're both on Imagine 2016 but he may have a more recent build. Could this be an issue?

 

Is there a list of error codes somewhere?

Technical Evangelist
Posts: 59
Registered: ‎09-16-2015

Re: Error running spatial model via Python

Does this happen with all models or just this one?  If it's just this one, can you open it in Spatial Model Editor in your version of IMAGINE, save it to a new file and try to open that one?  If that still fails, can you attach the model here?

 

There is not a list of error codes.  The code is just the line number in the source file where the error was thrown.  You should be getting a textual error message such as "Could not load Spatial Model: <filename>".  Can you tell me more about what you're doing and how you're running Python?  Do you have a Python script?  What Python development environment are you using?

 

Occasional Contributor
Posts: 5
Registered: ‎11-10-2015

Re: Error running spatial model via Python

Honestly this is my first time checking out spatial models in Python. I downloaded the Spatial Modeler 2016 Python examples and I'm plugging my own model into the example_load_model_and_execute.py script:

 

 

from imagine import modeler
from os.path import *

# Load a saved model
modelFile = r"D:\scripts\extract_bands_hardcoded.gmdx"
m = modeler.Solution.Load(modelFile)

# Run the model
m.Execute()
print('Finished running ' + modelFile)

The example model (saved_model.gmdx from the Python Examples) loads and runs, but mine doesn't, even though it appears to be well-formed XML. It is a very simple model made just to prove being able to run a model in Python. 

 

 

Here's the code, with some file paths changed for privacy, etc.

 

<?xml version="1.0" encoding="UTF-8"?>
<Solution xmlns="http://tempuri.org/XMLSchema.xsd" Version="2016">
	<Operator Namespace="IMAGINE" Name="Process">
		<DisplayName>Spatial Model</DisplayName>
		<Process>
			<Namespace></Namespace>
			<Name></Name>
			<DisplayName>Spatial Model</DisplayName>
			<DisplayCategory>General</DisplayCategory>
			<Description></Description>
			<Icon>Block.ico</Icon>
			<ColorCategory>Submodel</ColorCategory>
			<Keywords></Keywords>
			<UIProviderNamespace></UIProviderNamespace>
			<UIProviderName></UIProviderName>
			<IsUsableInExpression>false</IsUsableInExpression>
			<Syntax>Model (  )</Syntax>
			<Operators>Raster Input</Operators>
			<Operators>Raster Output</Operators>
			<Operators>Band Selection</Operators>
			<Tails>Raster Output</Tails>
		</Process>
	</Operator>
	<Operator Namespace="IMAGINE" Name="RasterInput">
		<DisplayName>Raster Input</DisplayName>
		<Port Name="Filename">
			<DisplayName>Filename</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>false</Hidden>
			<Data>
				<JsonValue>D:/input/test_raster.img</JsonValue>
				<Type Namespace="IMAGINE" Name="File"/>
			</Data>
		</Port>
		<Port Name="DataType">
			<DisplayName>DataType</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>true</Hidden>
		</Port>
		<Port Name="Interpolation">
			<DisplayName>Interpolation</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>true</Hidden>
		</Port>
		<Port Name="MapBoundary">
			<DisplayName>MapBoundary</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>true</Hidden>
		</Port>
		<Port Name="FileBoundary">
			<DisplayName>FileBoundary</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>true</Hidden>
		</Port>
		<Port Name="AOI">
			<DisplayName>AOI</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>true</Hidden>
		</Port>
		<Port Name="Recode">
			<DisplayName>Recode</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>true</Hidden>
		</Port>
		<Port Name="AttributesOnRasterOut">
			<DisplayName>AttributesOnRasterOut</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>true</Hidden>
			<Data>
				<JsonValue>true</JsonValue>
				<Type Namespace="IMAGINE" Name="Bool"/>
			</Data>
		</Port>
		<Port Name="ReadMetadata">
			<DisplayName>ReadMetadata</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>true</Hidden>
			<Data>
				<JsonValue>false</JsonValue>
				<Type Namespace="IMAGINE" Name="Bool"/>
			</Data>
		</Port>
		<Port Name="RasterOut">
			<DisplayName>RasterOut</DisplayName>
			<Description></Description>
			<Input>false</Input>
			<Output>true</Output>
			<Hidden>false</Hidden>
		</Port>
		<Port Name="AttributeTable">
			<DisplayName>AttributeTable</DisplayName>
			<Description></Description>
			<Input>false</Input>
			<Output>true</Output>
			<Hidden>false</Hidden>
		</Port>
		<Port Name="Metadata">
			<DisplayName>Metadata</DisplayName>
			<Description></Description>
			<Input>false</Input>
			<Output>true</Output>
			<Hidden>true</Hidden>
		</Port>
		<Port Name="NoData">
			<DisplayName>NoData</DisplayName>
			<Description></Description>
			<Input>false</Input>
			<Output>true</Output>
			<Hidden>true</Hidden>
		</Port>
		<Connections ParentPort="RasterOut" ChildDisplayName="Band Selection" ChildPort="RasterIn"/>
		<Attribute Name="FlowControl">
			<Data>
				<JsonValue>false</JsonValue>
				<Type Namespace="IMAGINE" Name="Bool"/>
			</Data>
		</Attribute>
		<Attribute Name="Orientation">
			<Data>
				<JsonValue>0</JsonValue>
				<Type Namespace="IMAGINE" Name="Int"/>
			</Data>
		</Attribute>
		<Attribute Name="PositionX">
			<Data>
				<JsonValue>153</JsonValue>
				<Type Namespace="IMAGINE" Name="Int"/>
			</Data>
		</Attribute>
		<Attribute Name="PositionY">
			<Data>
				<JsonValue>65</JsonValue>
				<Type Namespace="IMAGINE" Name="Int"/>
			</Data>
		</Attribute>
	</Operator>
	<Operator Namespace="IMAGINE" Name="RasterOutput">
		<DisplayName>Raster Output</DisplayName>
		<Port Name="RasterIn">
			<DisplayName>RasterIn</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>false</Hidden>
		</Port>
		<Port Name="FilenameIn">
			<DisplayName>FilenameIn</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>false</Hidden>
			<Data>
				<JsonValue>D:/output/test_output.img</JsonValue>
				<Type Namespace="IMAGINE" Name="File"/>
			</Data>
		</Port>
		<Port Name="PixelType">
			<DisplayName>PixelType</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>false</Hidden>
		</Port>
		<Port Name="BlockWidth">
			<DisplayName>BlockWidth</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>true</Hidden>
		</Port>
		<Port Name="BlockHeight">
			<DisplayName>BlockHeight</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>true</Hidden>
		</Port>
		<Port Name="Thematicity">
			<DisplayName>Thematicity</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>true</Hidden>
			<Data>
				<JsonValue>&quot;Same as Input&quot;</JsonValue>
				<Type Namespace="IMAGINE" Name="Thematicity"/>
			</Data>
		</Port>
		<Port Name="ComputePyramids">
			<DisplayName>ComputePyramids</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>true</Hidden>
		</Port>
		<Port Name="NoDataValue">
			<DisplayName>NoDataValue</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>true</Hidden>
		</Port>
		<Port Name="RasterOut">
			<DisplayName>RasterOut</DisplayName>
			<Description></Description>
			<Input>false</Input>
			<Output>true</Output>
			<Hidden>false</Hidden>
		</Port>
		<Port Name="FilenameOut">
			<DisplayName>FilenameOut</DisplayName>
			<Description></Description>
			<Input>false</Input>
			<Output>true</Output>
			<Hidden>false</Hidden>
		</Port>
		<Connections ParentDisplayName="Band Selection" ParentPort="RasterOut" ChildPort="RasterIn"/>
		<Parents>Band Selection</Parents>
		<Attribute Name="FlowControl">
			<Data>
				<JsonValue>false</JsonValue>
				<Type Namespace="IMAGINE" Name="Bool"/>
			</Data>
		</Attribute>
		<Attribute Name="Orientation">
			<Data>
				<JsonValue>0</JsonValue>
				<Type Namespace="IMAGINE" Name="Int"/>
			</Data>
		</Attribute>
		<Attribute Name="PositionX">
			<Data>
				<JsonValue>211</JsonValue>
				<Type Namespace="IMAGINE" Name="Int"/>
			</Data>
		</Attribute>
		<Attribute Name="PositionY">
			<Data>
				<JsonValue>406</JsonValue>
				<Type Namespace="IMAGINE" Name="Int"/>
			</Data>
		</Attribute>
	</Operator>
	<Operator Namespace="IMAGINE" Name="BandSelection">
		<DisplayName>Band Selection</DisplayName>
		<Port Name="RasterOut">
			<DisplayName>RasterOut</DisplayName>
			<Description></Description>
			<Input>false</Input>
			<Output>true</Output>
			<Hidden>false</Hidden>
		</Port>
		<Port Name="RasterIn">
			<DisplayName>RasterIn</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>false</Hidden>
		</Port>
		<Port Name="BandRange">
			<DisplayName>BandRange</DisplayName>
			<Description></Description>
			<Input>true</Input>
			<Output>false</Output>
			<Hidden>false</Hidden>
			<Data>
				<JsonValue>{&quot;Items&quot;:[{&quot;End&quot;:4.0,&quot;Start&quot;:1.0}]}</JsonValue>
				<Type Namespace="IMAGINE" Name="RangeList"/>
			</Data>
		</Port>
		<Connections ParentDisplayName="Raster Input" ParentPort="RasterOut" ChildPort="RasterIn"/>
		<Connections ParentPort="RasterOut" ChildDisplayName="Raster Output" ChildPort="RasterIn"/>
		<Parents>Raster Input</Parents>
		<Attribute Name="PositionX">
			<Data>
				<JsonValue>244</JsonValue>
				<Type Namespace="IMAGINE" Name="Int"/>
			</Data>
		</Attribute>
		<Attribute Name="PositionY">
			<Data>
				<JsonValue>241</JsonValue>
				<Type Namespace="IMAGINE" Name="Int"/>
			</Data>
		</Attribute>
	</Operator>
</Solution>

Thanks again.

Technical Evangelist
Posts: 714
Registered: ‎02-02-2016

Re: Error running spatial model via Python

Hi Evan,

 

We have moved this topic to the Support ERDAS IMAGINE forum.

 

Could you please log a support request for this issue? This will allow us to assist you directly to find a resolution.

 

Hexagon Geospatial Support: http://www.hexagongeospatial.com/support

US Federal Customers: Phone: 1-800-633-7248, eMail: supportdesk@intergraphgovsolutions.com

 

Regards,

 

Stephen Bent

Hexagon Geospatial Support