Make NetCDF Raster Layer via Phyton. RuntimeError: Object: Error in executing tool

559
2
05-08-2013 01:17 AM
JS1
by
New Contributor
I try to automize the creation of NetCDF Raster Layer via Phyton.
I used the tools help to get the basic syntax.

So a simple import from my data with this code works:
[PHP]
>>> import arcpy
>>> arcpy.MakeNetCDFRasterLayer_md("E:/Daten/Geodata/LPJ Outputs/hadley co2 konstant fix 2 mit single crops run/pft_harvest_maize.nc","harvest","longitude","latitude","test_netcdf_raster")
<Result 'test_netcdf_raster'>
[/PHP]

so that's no problem. No I would like to specify the dimension values within the same code. Unfortunatly the tools help doesn't provide an example for this but in the syntax description one can find [[dimension, {value}],...]...

So I tried the following:
[PHP]
>>> import arcpy
>>> arcpy.MakeNetCDFRasterLayer_md("E:/Daten/Geodata/LPJ Outputs/hadley co2 konstant fix 2 mit single crops run/pft_harvest_maize.nc","harvest","longitude","latitude","test_netcdf_raster_2","",[["time",{"1995"}]],"BY_VALUE")
[/PHP]

than I get this error message:
[PHP]
Runtime error
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\md.py", line 171, in MakeNetCDFRasterLayer
    raise e
RuntimeError: Object: Error in executing tool
[/PHP]

😞

so can anybody help me to fix this? Also I would be interested if there is a way to make a loop for this operation, so that I can create  NetCDF Raster Layers for the years from 1995-2005 in a loop...
any help would be apreciated.
Best johannes
0 Kudos
2 Replies
ShaunWalbridge
Esri Regular Contributor
The function mentions that it takes a Value Table for that parameter, so your values should be specified with a list of lists (or tuples), e.g:

[["time","1995"]]


You can also create an object to store the value tables, but I think the nested approach is simpler. You should also be able to use the 'flattened' syntax, which has each value pair separated by a semicolon:

'time 1995;time 1994'
0 Kudos
JS1
by
New Contributor
Thank you Shawn for your valuable comment. The following code solved my problem and I hope others can use it:

arcpy.MakeNetCDFRasterLayer_md("C:/pft_harvest_maize.nc","harvest","longitude","latitude","test_nedcf_raster_2","#","time 1995","BY_VALUE")

Still I started to use the R software environment to process my NetCDF Data. Comes with more speed and ease to process several layers and makes it possible to apply any given statistical Function on your Rasterdata. The results can be written to normal Rasterfiles and than be visualized our outlayed in ArcGIS. For anybody who is not afraid to use a little bit of code when working with raster data I would highly recommend R.
0 Kudos