Flow Path Parameters from 2D Line Python Error

4247
3
02-09-2015 08:50 AM
Labels (1)
JeffreyZimmerman__Jr_
New Contributor II

I am trying to run a python script in PythonWin that first creates the longest flow path for subwatersheds then computes the flow path parameters from 2D line.  I keep getting a error of "Object reference not set to an instance of an object" for the Flow Path Parameters from 2D line part of the script.  Here is my code, wondering if I'm missing something?  I'm using ArcMap 10.1 and Feb. 2014 ArcHydro release.

# Import arcpy module
import arcpy
import ArcHydroTools
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
arcpy.env.overwriteOutput = True

# Local variables:
ned10m = "L:\\srbcgis\\Projects\\Cumulative_Impacts\\Data\\Availability_Data\\ned10m"
Wshedtest = "C:\\CWUAS\\cwuas_10m.gdb\\CWUAS\\Wshedtest"
WshedtestPt = "C:\\CWUAS\\cwuas_10m.gdb\\CWUAS\\WshedtestPt"
Catchment = "C:\\CWUAS\\cwuas_10m.gdb\\CWUAS\\Catchment"
LFPCatchment = "C:\\CWUAS\\cwuas_10m.gdb\\CWUAS\\LFPCatchment"
fdrlake = "C:\\CWUAS\\Rasters\\CWUAS\\fdrlake"
LongestFlowPath = "C:\\CWUAS\\cwuas_10m.gdb\\CWUAS\\LongestFlowPath"
PTSLP_GP = "C:\\CWUAS\\cwuas_10m.gdb\\CWUAS\\PTSLP_GP"

# Process: Longest Flow Path for Subwatersheds
ArcHydroTools.LongestFlowPathForSubwatersheds(Wshedtest, WshedtestPt, Catchment, LFPCatchment, fdrlake, LongestFlowPath)

# Process: Flow Path Parameters from 2D Line
ArcHydroTools.FlowPathParametersFrom2DLine(LongestFlowPath, ned10m, PTSLP_GP)

0 Kudos
3 Replies
XanderBakker
Esri Esteemed Contributor

This is typically a COM error (might be from your ArcHydro installation). Don't think the error is caused by your python script. Could you show the complete error anyhow?

If you perform this manually, with the same data, does the error still occur?

0 Kudos
JeffreyZimmerman__Jr_
New Contributor II

I can run the tool in ArcMap with no problems.  I also created a ModelBuilder model first and ran it successfully.  I then exported it to a python script.  When I run it from PythonWin, I get the below error.  Seems like ArcMap has something running that the tool needs, but when taken out of the ArcMap world, it errors.  I am downloading the 1/22/2015 ArcHydroTools10.1x64 version now.

Here is the complete error:

Traceback (most recent call last):

  File "C:\Python27\ArcGIS10.1\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript

    exec codeObject in __main__.__dict__

  File "L:\srbcgis\Projects\Cumulative_Impacts\Data\Availability_Data\MNSLP_GP.py", line 35, in <module>

    ArcHydroTools.FlowPathParametersFrom2DLine(LongestFlowPath, ned10m, PTSLP_GP)

  File "C:\Program Files (x86)\ESRI\WaterUtils\ArcHydro\bin\ArcHydroTools.py", line 6668, in FlowPathParametersFrom2DLine

    raise e

ExecuteError: Object reference not set to an instance of an object.

Failed to execute (FlowPathParametersFrom2DLine).

0 Kudos
JeffreyZimmerman__Jr_
New Contributor II

I am still getting the same error after installing the 1/22/2015 ArcHydro 10.1 release.  I also added the following code to the script, but it still gives the same error:

ArcHydroTools.SetTargetLocations("HydroConfig", "Layers", "C:\\CWUAS\\Rasters\\CWUAS", "C:\\CWUAS\\cwuas_10m.gdb")

0 Kudos