Multidimensional zonal statistics

675
5
09-24-2013 04:18 AM
FabienCottier
New Contributor
Hello,

I'm posting here as I encountered a bug using the multidimensional zonal statistics script from the multidimensional supplemental tool <http://www.arcgis.com/home/item.html?id=9f963f362fe5417f87d44618796db938>. Using data from the global precipitation dataset (0.5 degree cell netCDF file, with separate band for  month from 1901 to 2010), I would like to compute the amount of precipitation by administrative zone for Kenya per year (I use the GAUL dataset -feature class dataset- for the first administrative order).

I'm however stuck at the first step, which consists in getting the total amount of precipitation for each kenyan administrative zone for each time band. When using the multidimensional zonal statistics script, I get an error in python, whereby it appears that there is an error with the SnapRaster. I'm surprised to get this error, since the zone field is a feature layer (the gaul dataset). Anyway, I did try also using a raster conversion (with 05. degree cell) of the polygon GAUL layer, but I still get the same error, as well as when I tell arcpy explicitly to consider the gaul raster, as the snap raster (in the environment variable).

To be honest, it is the first time, I'm using netCDF file and I'm a bit lost here ;)

So I would appreciate any help to overcome this issue!

Many thanks and best wishes,
Fabien

PS: feel free to contact me if you need more details.
0 Kudos
5 Replies
AdamWehmann
New Contributor II
Hi Fabien,

What version of ArcGIS are you running?  Can you post the error output here?

- Adam
0 Kudos
FabienCottier
New Contributor
Hi Adam,

Thanks for your reply. I use ArcGIS 10.1 with service pack 1 (arcinfo licence).

Here is the error output:

Traceback (most recent call last):
  File "C:\Users\COTTIERF\Documents\ArcGIS\MultidimensionSupplementalTools\Scripts\mds\tools\multidimensional_zonal_statistics_as_table.py", line 442, in execute
    self.zonal_statistics_as_table_for_grid(parameters, messages, dataset)
  File "C:\Users\COTTIERF\Documents\ArcGIS\MultidimensionSupplementalTools\Scripts\mds\tools\multidimensional_zonal_statistics_as_table.py", line 567, in zonal_statistics_as_table_for_grid
    arcpy.env.snapRaster = temp_snap
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\geoprocessing\_base.py", line 529, in set_
    self[env] = val
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\geoprocessing\_base.py", line 581, in __setitem__
    ret_ = setattr(self._gp, item, value)
RuntimeError: Object: Error in accessing environment <snapRaster>

Failed to execute (MultidimensionalZonalStatisticsAsTable).


Best regards and thanks for your help!
Fabien
0 Kudos
AdamWehmann
New Contributor II
Hi Fabien,

First, check that you are using version 1.2 of the Multidimension Supplemental Tools.

Then, simply replace the line 533:

arcpy.env.snapRaster = temp_snap


with:

arcpy.env.snapRaster = temp_snap.catalogPath


This is a datatype mismatch.   In ArcGIS 10.1, the snapRaster environment setting expects string input, but it was given a raster input.  The code will function as-is in 10.2 due to some datatype coercion.

Cheers,

Adam
0 Kudos
FabienCottier
New Contributor
Hi Adam,

Thanks a lot for the help. I'm away at a workshop for the week-end, but I'll have a look at it once I'm back in the office next week. I'll let you know how does this work.

With my best wishes and thanks again!
Fabien
0 Kudos
FabienCottier
New Contributor
Hi Adam,

Thanks a lot for the help, changing the arcpy.env.snapRaster did correct the bug! I could compute statistics both with a raster and shapefile as zone field. The only remaining issue is with when a feature class stored in a geodatabase is used as a zone field, in this case, I get the following error message:

Not a valid zone dataset.

Traceback (most recent call last):
  File "C:\Users\COTTIERF\Documents\ArcGIS\MultidimensionSupplementalTools\Scripts\mds\tools\multidimensional_zonal_statistics_as_table.py", line 442, in execute
    self.zonal_statistics_as_table_for_grid(parameters, messages, dataset)
  File "C:\Users\COTTIERF\Documents\ArcGIS\MultidimensionSupplementalTools\Scripts\mds\tools\multidimensional_zonal_statistics_as_table.py", line 612, in zonal_statistics_as_table_for_grid
    raise arcpy.ExecuteError
ExecuteError

Failed to execute (MultidimensionalZonalStatisticsAsTable).


This not a very important issue, since I can always export my feature class stored in a geodatabase in a shapefile, but I thought that you wish to be aware of it.

Many thanks for the help and all the best!
Fabien
0 Kudos