0

I am trying to create a raster layer from a NetCDF File using Python. If I am using the Arcgis 10 Python window it works without issues. But executing the same script in Pythonxy gives the error:

NetCDF: Attribute not found

What could be the problem? I'm just wondering because it works within the Arcgis working area but not outside.

Here's my python code:

import arcpy

inNetCDFFile = 'C:/Users/Babs/Dropbox/Masterarbeit/mpihm_cnrmb1nat_precip_monthly_1991_2000.nc'

variable = 'Precip'

XDimension = 'lon'
YDimension = 'lat'

outRasterLayer = 'Precip_2011'
bandDimension = ''
dimensionValue = ''
valueselectionmethod = ''

arcpy.MakeNetCDFRasterLayer_md(inNetCDFFile, variable, XDimension, YDimension,
outRasterLayer, bandDimension, dimensionValue,valueselectionmethod)

1 Answer 1

1

I tried a similar script using ArcMap 10.1, and it worked fine in both ArcMap python and in Enthought Canopy (similar to Python(x,y)). Here's my script:

import arcpy
import urllib

inNetCDFFile = 'C:/rps/bathy/gom/bathy_crm_vol.nc'  
urllib.urlretrieve('http://geoport.whoi.edu/thredds/ncss/grid/bathy/crm_vol1.nc?var=topo&north=42&west=-71&east=-70&south=41&horizStride=2&addLatLon=true',
    inNetCDFFile)

variable = 'topo'
XDimension = 'lon'
YDimension = 'lat'

outRasterLayer = 'arc_rps_bathy'
bandDimension = ''
dimensionValue = ''
valueselectionmethod = ''
outDir = "c:/rps/python/"

arcpy.MakeNetCDFRasterLayer_md(inNetCDFFile, variable, XDimension, YDimension,
outRasterLayer, bandDimension, dimensionValue,valueselectionmethod)
arcpy.CopyRaster_management(outRasterLayer, outDir + outRasterLayer + ".img"

Perhaps the versions of Python and numpy in your version of Python(x,y) are not compatible with the ArcGIS 10.0 Python and numpy versions? See this post about getting Enthought Canopy to play nice with ArcGIS 10.1: How to access Esri ArcPy modules from Enthought Canopy?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.