Zonal stats: fail to open raster dataset for a multi-band tiff.

2692
14
12-06-2011 06:45 AM
RichardThurau
Occasional Contributor
Hi,
Trying to extract some values from some tiny AOI polygons from multiple bands of a .tif.

AOI = "X:\\aoi.shp"
Img1_1 = "X:\\Glovertown_in_1.tif\\Band_1"
tab_1_1 = "X:\\Tab1_1"

Tab1_1 = ZonalStatisticsAsTable(AOI, "OBJECTID", Img1_1, "tab_1_1", "", "MINIMUM")



error:
ExecuteError: ERROR 999999: Error executing function.
Failed to open raster dataset
Failed to execute (ZonalStatisticsAsTable).

Can anyone tell me what's going wrong here?

Thanks

Rich
Tags (2)
0 Kudos
14 Replies
ChrisSnyder
Regular Contributor III
Try

Tab1_1 = ZonalStatisticsAsTable(AOI, "OBJECTID", Img1_1, tab_1_1, "", "MINIMUM")

instead of

Tab1_1 = ZonalStatisticsAsTable(AOI, "OBJECTID", Img1_1, "tab_1_1", "", "MINIMUM")
0 Kudos
RichardThurau
Occasional Contributor
Chris,
I tried that as well, right after I posted. No Dice.

The tools says it supports floating rasters for the minimum statistic. Hoping not to have to create a bunch of extra output just to convert to int, which is my current hunch.

Thanks for the reply.

Rich
0 Kudos
ChrisSnyder
Regular Contributor III
What if you convert band1 of your .tif to a grid... Does it work then? Maybe ZonalStats doesn't like using multiband .tif files as input?
0 Kudos
RichardThurau
Occasional Contributor
Chris,
That is possible but this is a small piece of code for a larger project.
1. If I have to convert everything to grid, it's probably a deal breaker. I'll just work it out in SML in ERDAS. I'm trying to use python because it would allow me to automate a bit further down the line.

2. I've seen other people (code examples in these forums) work successfully with .tif

Thanks

RT
0 Kudos
ChrisSnyder
Regular Contributor III
I ran a little test, and I was able to use Band_1 from a multiband .tif in the Zonal Statistics as Table tool via ArcToolbox.

arcpy.ZonalStatisticsAsTable(roadshedFC, "ROADSHED_ID", r"C:\temp\test.tif\Band_1", outZnStatsTbl, "", "ALL")

Maybe it's just the map algebra is wonkey...

Does the toolbox tool work for you?
0 Kudos
RichardThurau
Occasional Contributor
Thanks for your persistence Chris,
Yes, of course (sarcasm) the tool runs fine. Unfortunately, this isn't going to be very useful in the grand scheme.
Here's the tool, python snipet:
arcpy.ZonalStatisticsAsTable_sa("X:/aoi.shp","OBJECTID","X:/image_in_1.tif/Band_1","x:/zonalst_glovert1","DATA","MINIMUM")


But we have made progress. What's wrong with this code?
0 Kudos
ChrisSnyder
Regular Contributor III
Try using a different field than OBJECTID from your AOI polygon. Used to be that OBJECTID wasn't an allowed field for any SA tools. Now it seems to be okay, but sometimes the ESRI tools revert to past behaviors...

What if you use the "ALL" default for the statistic type? Better yet, just use "" to force the default value.
0 Kudos
RichardThurau
Occasional Contributor
Chris, no dice.
Trying default values as you suggested. Created an IMG, didn't work. Brought the IMG into a GDB, didn't work. All the same error "failure to open raster dataset".

Where is Python disconnected from the tool? I had a similar problem with Mosaic a while back, where python wouldn't run, but the tool does. I ended up having to do something completely different just to work around.

Anyone have any foundational wisdom here?

Chris probably needs some relief! I know I do.

RT
0 Kudos
Luke_Pinner
MVP Regular Contributor
I've had trouble with ZonalStats using objectid fields previously. Try using another field of SmallInteger or Integer type, no floating points (i.e. Double) or text.

You also need to make sure that the ArcGIS ScratchWorkspace environment setting (or the Windows %TEMP% environment variable) points to a path without spaces as ArcGIS writes temporary grids there and will fail with a very unhelpful error message if the path has spaces.
0 Kudos