Select to view content in your preferred language

ArcHydro Wetland Identification (WIM) - Train Test Split Tool giving HRESULT E_FAIL error

2276
13
Jump to solution
10-22-2022 10:35 PM
Labels (2)
MalloryGill
Occasional Contributor

I've been using the WIM toolset for wetland identification successfully for a few months now, but I tried to open the "Train Test Split" tool yesterday and I'm now getting the error "Error HRESULT E_FAIL has been returned from a call to a COM component." The error shows up instead of the usual tool parameter options, so many of the recommended problem solver suggestions for the "HRESULT" errors don't apply in that I can't modify geoprocessing extent or the location of data, etc since I can't even get to the parameters for the tool in the first place. The rest of the tools in the WIM set all open the parameter options and everything I've spot-checked in Archydro also works as expected.

My inclination is that it's related somehow to the archydro tools themselves or scikit-learn python package since it's bombing as soon as I try to open it and not showing any parameters. If I try to "edit" the Train Test Split tool from catalog, it says the script is empty but if I navigate manually to the traintestsplit.py file the script opens and looks as expected. 

I'm currently running ArcGIS Pro 2.9.3, ArcHydro tools 2.9.59, so the versions should be aligned.  I've tried the doable recommended ArcHydro problem solvers to no avail (restarts, new mxd, clearing temp folder). Anyone experienced something similar or have any ideas? ( @GinaO_Neil I'm hoping you have some magic up your sleeve! 🤞)

Thanks!

0 Kudos
1 Solution

Accepted Solutions
GinaO_Neil
Esri Contributor

Hi @MalloryGill,

Thanks for reaching out. I believe this is a an error in the arc hydro tools themselves, as you suggested. We are working on resolving conflicts in tools that are developed in Pro 3 and then used in Pro 2.9. Unfortunately the Train Test Split tool falls in this category. We are prioritizing a fix to this issue and will have new version of WIM available in the next couple of weeks (this will include additional new WIM functionality!).

In the meantime I recommend trying the tools in Pro 3, or (more stable) downgrade to the arc hydro version just before 2.9.59.

View solution in original post

0 Kudos
13 Replies
GinaO_Neil
Esri Contributor

Hi @MalloryGill,

Thanks for reaching out. I believe this is a an error in the arc hydro tools themselves, as you suggested. We are working on resolving conflicts in tools that are developed in Pro 3 and then used in Pro 2.9. Unfortunately the Train Test Split tool falls in this category. We are prioritizing a fix to this issue and will have new version of WIM available in the next couple of weeks (this will include additional new WIM functionality!).

In the meantime I recommend trying the tools in Pro 3, or (more stable) downgrade to the arc hydro version just before 2.9.59.

0 Kudos
MalloryGill
Occasional Contributor

Thanks so much Gina! I ended up finding a workaround - I'm working on a standalone python script that predicts wetlands (using the WIM tools) and calculates impacted wetland areas for project locations. And I was able to call the Train Test Split tool successfully from my standalone python script to generate the train and test rasters without getting the error message.

I'll definitely keep an eye out for the upgrade in the next few weeks, thanks again for your help!

0 Kudos
by Anonymous User
Not applicable

Hi @MalloryGill , would you mind sharing the code snippet that calls in the Train Test Split tool, if convenient? Thanks!

0 Kudos
MalloryGill
Occasional Contributor

Sure thing! Code is below, it's part of a larger python toolbox I'm building. We'll be iterating through different geographic areas and running the tools, so the class dictionary just allows for flexibility in how many classes there might be in a raster. If you had just a single location or a consistent set of classes you could hard code a single sampling percentage string and cut out everything above line 21

# build class dictionary for sampling percents
class_dict = {}
class_dict[9] = "0 25;1 50;2 50;3 50;4 50;5 50;6 50;7 50;8 50;9 50"
class_dict[8] = "0 25;1 50;2 50;3 50;4 50;5 50;6 50;7 50;8 50"
class_dict[7] = "0 25;1 50;2 50;3 50;4 50;5 50;6 50;7 50"
class_dict[6] = "0 25;1 50;2 50;3 50;4 50;5 50;6 50"
class_dict[5] = "0 25;1 50;2 50;3 50;4 50;5 50"
class_dict[4] = "0 25;1 50;2 50;3 50;4 50"
class_dict[3] = "0 25;1 50;2 50;3 50"
class_dict[2] = "0 25;1 50;2 50"
class_dict[1] = "0 25;1 50"

# determine how many classes are present in raster
ds = gdal.Open(wetland_path)
arcpy.AddMessage(ds)
band = ds.GetRasterBand(1)
arcpy.AddMessage(band)
max_val = band.GetMaximum()
arcpy.AddMessage(max_val)
if max_val in class_dict:
	sample_pct = class_dict[max_val]
	arcpy.AddMessage(f'{wetland_name} has {max_val} wetland classes - sampling perentages {sample_pct}')
	
	# train test split
	arcpy.AddMessage(f'Building train and test split for grid {pagenum}...')
	train_name = f'grid_{pagenum}_train.tif'
	test_name = f'grid_{pagenum}_test.tif'
	train_path = os.path.join(model_folder_path, train_name)
	test_path = os.path.join(model_folder_path, test_name)
	p_traintest = traintestsplit.TrainTestSplit()
	ret_traintest = p_traintest.executeAH(in_gt_ras=wetland_path,
										  out_train=train_path,
										  out_test=test_path,
										  in_class_sampling_percent=sample_pct)

else: 
	arcpy.AddError(f'Sampling percentages not found for {max_val} class raster. Exiting.')

 

by Anonymous User
Not applicable

Hi Gina, I am using Pro 2.9.5 and just installed Arc Hydro 2.9.79. I am still receiving the same error with the Train Test Split tool. Just wanted to let you know. Thanks! 

0 Kudos
GinaO_Neil
Esri Contributor

Hey there. Thanks for the heads up! I still need to submit changes for the Arc Hydro Pro 2.9 build to fix this issue. The tools should all be working, and with added capability, in the Arc Hydro Pro 3 version. Are you able to upgrade? I will be working to fix these Pro 2.9 issues this week.

0 Kudos
by Anonymous User
Not applicable

Good to know. I will be able to upgrade in the coming months and will try the 3.0 tools then. Thank you!

GinaO_Neil
Esri Contributor

We just posted a new Pro 2.9 build that should fix these issues. The tools also incorporate nearly all of the Pro 3 functionality (all but Continuous Flow). Let me know if you are still running into issues. Thanks!

Download here https://downloads.esri.com/archydro/archydro/Setup/Pro/2.9/

0 Kudos
MalloryGill
Occasional Contributor

Awesome - thanks for the heads up!