POST
|
Hi all - I'm trying to use the Slice tool to group a script's result raster by a user-defined X%, which seems straightforward enough. The resulting value distribution may not be normally distributed, which, the Slice doc says, is not optimal for use of the tool. Now, I understand that using the EQUAL_INTERVAL method may produce empty classes, or classes with very few cells. That makes sense because there just may not be cells with values that fall within the interval. However, often when I use EQUAL_AREA I also get empty classes, which doesn't make sense to me, and the doc doesn't explain why this might happen. It seems that if it's basing the grouping on area (which is always there) and not just value, there's no chance of missing values, unlike EQUAL_INTERVAL. Can anyone shed light on why this would happen? As it is, I might have to write my own Slice command to get better results. Thanks! ~ Stacie
... View more
03-28-2013
02:30 PM
|
0
|
2
|
837
|
POST
|
Hi Peter - I've got a basic working version of my script that goes from DEM to watersheds, including formatting a user's outlet point shapefile to have the fields required for batch points. Attaching it here in case it's of use... ~ Stacie
... View more
02-08-2013
10:29 AM
|
1
|
1
|
897
|
POST
|
Christine reminded me that we cannot use shapefiles for either input or output. So I just got past the AdjointCatchment error by directing everything to a geodatabase, and the whole script works. ~ Stacie
... View more
01-14-2013
06:45 PM
|
0
|
0
|
897
|
POST
|
Woohoo! That helped - I can now call ArcHydro tools within the python script. Thanks, Christine! So far, most tools that I've tried ran fine (I'm working up to creating watersheds and sub-watersheds), except AdjointCatchment, where I got this error: System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component. at ESRI.ArcGIS.Geoprocessing.GeoProcessorClass.Execute(String Name, IVariantArray ipValues, ITrackCancel pTrackCancel) at ESRI.APWR.ApHydro.ArcHydroOp.AdjointCatchmentProcessing(ApLayers apLayers, Int32 debug, ITrackCancel& trackcancel, IGPMessages& messages, String& exMessage, String& tempwkdir) in C:\Builds\HydroSolutions\10.0_ArcHydro\Sources\ArcHydroTools\src\ApHydro\ArcHydroOp.vb:line 48825 Failed to execute (AdjointCatchment). Catchment polygons and Drainage lines ran fine (although some of the resulting columns contain all zeroes like DrainID and NextDownID) and the adjoint catchment shapefile was created but only contains column names. Any idea what's happening? I can provide additional info if necessary, just let me know what's helpful. Thanks again... ~ Stacie
... View more
01-10-2013
05:58 PM
|
0
|
0
|
897
|
POST
|
Hi all - I've used ArcHydro quite a bit over the years, done a lot of python geoprocessing too, but this is the first time I've tried to script ArcHydro in python. I just don't seem to be able to run any ArcHydro tools from my python script, there's no explicit error as to why, just a generic script failure. If I do ListToolboxes within the script, ArcHydro is there, if I do ListTools, the ArcHydro tools that I'm calling are there. But when I try to run any of the tools, the script just fails. This is with ArcGIS 10 and ArcHydro 2.0. Since it looks like Arc already knows about ArcHydro (from being able to list the toolbox and tools), I'd think that I wouldn't need to use ImportToolbox (and would rather not have to, since I'm making a tool to provide to others so don't want to hard-code or ask for paths), but I tried that anyway and the script just hangs on this command: arcpy.ImportToolbox("C:\Program Files (x86)\ArcGIS\Desktop10.0\ArcToolbox\Toolboxes\Arc Hydro Tools.tbx") If I don't try to import, the first thing the script was doing is a Flow Direction: workspace = arcpy.GetParameterAsText(0) DEM = arcpy.GetParameterAsText(1) interws = workspace + os.sep + "Intermediate" + os.sep sshed_gdb = interws + "ssheds.gdb" flow_dir = interws + "flow_dir" arcpy.FlowDirection_archydro(DEM, flow_dir) Maybe it doesn't like the flow_dir setting the whole path, since AH has its own default locations set, so try this: arcpy.FlowDirection_archydro(DEM, "flow_dir") Doesn't work. Maybe it doesn't have its own default locations set, so try setting them: arcpy.SetTargetLocations_archydro("HydroConfig", "Layers", interws, sshed_gdb) Doesn't work, still no explicit error. Try creating the gdb first, doesn't help. Checked the XML Vector Location Type, it's set to 1 (gdb), Raster to 2 (can't find doc on that, but the RasterLocation is set to a folder by default, so I'm hoping 2 means folder.) All of this works fine using these folders, file names and file types when I run the ArcToolbox tools manually outside of the script. Put this through a debugger and get this error message: AttributeError: 'module' object has no attribute 'FlowDirection_archydro' I must be missing something basic. Any clues as to what are greatly appreciated... ~ Stacie
... View more
08-21-2012
01:28 PM
|
0
|
11
|
7573
|
POST
|
That worked! Thanks a lot, Curtis. I still don't understand how I've gotten away with using this same code for 4 years without this happening, but such are the vagaries of ArcGIS I guess. Of note, there is no "~" or any other odd character in the path that I enter - I learned that lesson a long time ago. Something in the interpreter was munging my input. And I've learned something about using raster layers. In general I've found them inconvenient because they don't exist anywhere that I can look at them while debugging or just tracing my algorithm's results, but it appears that they have other benefits. Thanks again... ~ Stacie
... View more
06-05-2012
01:19 PM
|
0
|
0
|
315
|
POST
|
Hi Curtis - The whole script is rather long. Here are the relevant bits, but if you actually want the whole script, I can post it. # Early in script, define hydrology layers, global variables - this code has been used and re-used for years and worked fine on all Arc versions
outputws = gp.workspace + os.sep + "Output" + os.sep
Hydrows = outputws + "Hydro_layers" + os.sep
if not gp.exists(Hydrows + "flow_dir"):
# Create flow direction raster
gp.FlowDirection_sa(DEM, Hydrows + "flow_dir", "NORMAL")
flow_dir = Hydrows + "flow_dir"
if not gp.exists(Hydrows + "flow_acc"):
# Create flow accumulation raster
gp.FlowAccumulation_sa(Hydrows + "flow_dir", Hydrows + "flow_acc", "", "FLOAT")
flow_acc = Hydrows + "flow_acc"
# Later, set flow direction raster to null where there are streams
def define_channels():
try:
gp.AddMessage("\nDefining flow direction channels...")
exp = "\"VALUE\" > " + str(int(threshold_flowacc))
# THIS IS WHERE THE ERROR OCCURS
gp.SetNull_sa(flow_acc, flow_dir, flowdir_channels, exp)
# ALTO TRIED THIS
gp.SingleOutputMapAlgebra_sa("CON(" + flow_acc + " <= " + threshold_flowacc + ", " + flow_dir, ")", flowdir_channels)
except:
gp.AddError ("\nError defining flow direction channels: " + gp.GetMessages(2))
raise Exception I tried taking this out of a function and putting it into the main body of code, hard-coding the path as a string, using one of the script inputs in place of the generated flow_acc (for the heck of it), all produced the similar errors. Also tried fussing with inputting filename backslashes as either "\" or "\\", didn't help. When trying the CON code, the error is a bit different: ERROR 010394: Map Algebra expression: Syntax error at location 3 (around (G:\G) of expression CON(G:\GIS\scratch\tmp_rios_preproc2\Output\Hydro_layers\flow_acc <= 1100, G:\GIS\scratch\tmp_rios_preproc2\Output\Hydro_layers\flow_dir. Thanks for taking a look at it... ~ Stacie
... View more
06-05-2012
10:25 AM
|
0
|
0
|
315
|
POST
|
Hi all - I developed a python script and toolbox on Arc 10, where it worked fine. Exported the toolbox to 9.3 and now I'm trying to run it on 9.3.1 and something is happening that I've never seen before (after writing and running a lot of geoprocessing scripts in 9.2, 9.3 and 10.) In the script I successfully create a flow accumulation grid, then use it in a SetNull statement. When SetNull runs, I get this error - the path is totally garbled: ERROR 010316: Unable to open the input grid: G:GISSCRATCHTMP_RI~2OUTPUTHYDRO_~1LOW_ACC ERROR 010067: Error in executing grid expression. Failed to execute (SetNull). Yet, if I print out the grid path right before running SetNull, it looks like this, which is correct: G:\GIS\scratch\tmp_rios_preproc2\Output\Hydro_layers\flow_acc There's no problem adding the grid to the map, its folder appears correctly in the Properties. Then if I try to, say, do a math computation on it, that works fine, as does Extract by Mask (just trying things randomly.) However, if I try the same SetNull command from ArcToolbox, or Con, I get the same error as above. The same grid is used in SingleOutuptMapAlgebra within the script with no problems. It doesn't matter if I write everything to a different directory or disk. I tried restarting the .mxd, tried making a new .mxd, tried making a whole new toolbox using 9.3.1, even tried rebooting the whole darn machine, nothing helps. Has anyone else run into this? Thanks! ~ Stacie
... View more
05-25-2012
02:08 PM
|
0
|
5
|
464
|
POST
|
Hi Ruby - I wish I could tell you exactly what fixed it, other than a tech at ESRI fussed with my machine for so long that I stopped paying attention (very sorry that I didn't at least note the final fix.) What I do remember is that there were python libraries from an old version of python where they shouldn't have been, like an old distribution that didn't uninstall correctly. ArcMap was apparently looking in this wrong folder, which existed but didn't have all of the necessary files. What I can recommend is uninstalling your version of python, then look around on the machine for any python installation files/folders that might not have been cleaned up (maybe do a whole system search to be sure) and delete them. Also look in your system Environment variables, in case there's a path pointing to a wrong place. Reboot, then try installing again. ~ Stacie
... View more
03-27-2012
05:20 PM
|
0
|
0
|
759
|
POST
|
I resolved the error by specifying a geodatabase layer as the output instead of a shapefile. Using Arc 10 and ArcHydro 2, run the commands from ArcToolbox. The output filename should look something like this: D:\GIS\Ecuador\ecuador_w74.gdb\Layers\AdjointCatchment not this: D:\GIS\Ecuador\output\AdjointCatchment.shp That's all I had to do... ~ Stacie
... View more
02-06-2012
07:09 AM
|
0
|
0
|
1276
|
POST
|
Hi, all - I just spent way too much time debugging something that I probably should have known, so wanted to post it here in case it saves someone else time. In a nutshell, ArcHydro does not output to shapefiles, only geodatabases. And if you specify a shapefile as the output to something like Batch Watershed Delineation, you get an error like this: System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component. at ESRI.ArcGIS.Geoprocessing.GeoProcessorClass.Execute(String Name, IVariantArray ipValues, ITrackCancel pTrackCancel) at ESRI.APWR.ApHydro.GDBHelper.AddFieldGP(ApLayer apLayer, String fieldTag, String& exMessage) in C:\Projects\10_Final\ArcHydroTools\src\ApHydro\GDBHelper.vb:line 1307 I love ArcHydro, but do wish that the error messages were more user-friendly. ~ Stacie
... View more
01-26-2012
08:36 AM
|
0
|
12
|
8760
|
POST
|
This is happening to me as well, using Arc 9.3.1. Hollie is actually using our tools, so this problem might end up effecting a lot of our users, so any insights would be appreciated. Here's a bit more info. It's happening within a Python script (actually, a couple of them) where I've done a bunch of raster calculations (very different in each script) and in the end aggregate the results using Zonal Statistics, where the zone file is a shapefile of watersheds. One odd thing I'm seeing in one of the rasters that fails with this error is that when I look at its Statistics, the Mean value is 1.#QNAN, and Calculate Statistics will not work on it (CS tells me that it's invalid when I try to add it to the dialog box.) If I turn the watershed file into a raster, initial tests are showing that Zonal Stats can work, but Zonal Stats as Table does not (using either shapefile or raster zones), but returns a different error: ERROR 010067: Error in executing grid expression. Zonal statistics program failed Failed to execute (ZonalStatisticsAsTable). Now, the QNANs first appear when I do a Lookup_sa on a raster with a bunch of fields, created by doing a join between a watershed raster and a table, then a CopyRaster to a new grid. This new grid looks fine and has proper Statistics. The resulting Lookup values and maps look good, but the Statistics say Min 89, Max 1701, Mean 1.#QNAN, Std dev 0, Classes 0. Zonal Stats as Table seems to work fine on rasters that have proper statistics, but not on those with a Mean of QNAN. Could be coincidence, but it's the only thing that looks obviously amiss. ~ Stacie
... View more
03-14-2011
09:00 AM
|
0
|
0
|
395
|
POST
|
Hi, Jason - I wish I could help, but instead this is a Me Too post. After 8 hours of running Drainage Line, I finally got to Adjoint Catchment, got the same Null error and see the same Null values in the Catchment layer. Sigh. Too bad, as I was trying ArcHydro 1.4 because 1.3 also failed in Adjoint Catchment, but didn't throw an error, just returned an empty shapefile. So tantalizingly close to actually generating watersheds. Does anyone know of any other tools out there that will delineate multiple, often nested watersheds at a time accurately given a point outlet layer? ArcSWAT seems to merge the resulting basins together, so you don't get a separate one for each outlet if they're nested or adjacent. AGWA only lets you do one at a time, and since I'm trying (fruitlessly) to generate watersheds for all of the major dams in the world, I want to do them in batch. ~ Stacie
... View more
03-07-2011
06:48 PM
|
0
|
0
|
202
|
POST
|
Thanks - I'll give it a try. It will at least be a workaround until I figure out the underlying problem. ~ Stacie
... View more
10-18-2010
01:48 PM
|
0
|
0
|
759
|
POST
|
Hi, all - I've just installed ArcMap 9.3.1 and am trying to use numpy in a Python script called from ArcToolbox, but I get this error: <type 'exceptions.ImportError'>: No module named numpy. I know it's installed, and if I bring up a python shell and "import * from numpy" it works fine. Spatial Statistics tools don't work either, some giving the same numpy error as above, others with variations on this: <type 'exceptions.ImportError'>: Bad magic number in C:\Program Files (x86)\lib\subprocess.pyc. Sometimes the error is for random.pyc. So far I've tried reinstalling just python and numpy, didn't help, nor did reinstalling all of 9.3.1. I made sure that there are no older versions of python on the machine and either deleted or renamed every ArcMap/ESRI directory I could find, in case an old setting was hanging around. I'm starting to think that there's a greater problem, as I tried Arc 10 and it was a nightmare, crashing regularly and with missing libraries (functools when trying to use Raster Calculator), when a colleague running the same OS (Windows XP Professional x64) has had none of the same problems with either 9.3.1 or 10. Any ideas would be greatly appreciated... ~ Stacie
... View more
10-12-2010
07:18 PM
|
0
|
6
|
4577
|
Title | Kudos | Posted |
---|---|---|
1 | 02-08-2013 10:29 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|