[gdal-dev] Reading a NetCDF file with python (not recognised as a supported dataset name

Kyle Shannon KShannon at gcs-research.com
Fri Jun 8 08:08:50 PDT 2012


Etienne, Rutger,
I can reproduce on windows with 32 bit 1.9 branch and 1.9.1 from Tamas' site.  In fact, I couldn't open any datasets.

kss

-----Original Message-----
From: gdal-dev-bounces at lists.osgeo.org [mailto:gdal-dev-bounces at lists.osgeo.org] On Behalf Of Etienne Tourigny
Sent: Friday, June 08, 2012 9:10 AM
To: Rutger
Cc: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] Reading a NetCDF file with python (not recognised as a supported dataset name

Rutger,

There should not be any difference when using the python bindings. If gdalinfo can read it the python bindings should also.

I cannot reproduce your problem using gdal-1.9.1 under linux.  Which exact version are you using?

By the way, the vrtfile in unnecessary, because GDAL's Open accepts the NETCDF:file.nc:variable syntax.

Try adding this to your script and send the result back here gdal.SetConfigOption( 'CPL_DEBUG', 'ON' )

also try gdal_info.exe -stats
NETCDF:LPRM-TMI_L3_DY_SOILM3_V001-20120411T144114Z_20120102.nc:soil_moisture_x
this actually reads the file contents and not just the metadata. If it fails then something is wrong.

you should see
    STATISTICS_MAXIMUM=99
    STATISTICS_MEAN=21.746993313128
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=20.100893016522


Etienne

On Fri, Jun 8, 2012 at 9:00 AM, Rutger <kassies at gmail.com> wrote:
> Dear list,
>
> I am trying to open a NetCDF file with the Python bindings. My GDAL 
> 1.9 build (Win32 from Tamas) shows the NetCDF driver when i run 
> "gdalinfo --formats", so it should be possible.
>
> When using the pre-build command-line utilities all works well. But 
> when i move to Python i get the message:
> /" ... does not exist in the file system, and is not recognised as a 
> supported dataset name."/ I dont have the slightest clue about what 
> i'm doing wrong.
>
> I have simplified the problem to 3 steps:
> 1. Use gdal_translate to select a subdataset and output to VRT 2. Read 
> the VRT in Python with gdal.Open() 3. Use gdal_translate to convert 
> the VRT to a Geotiff
>
> Step 1 & 3 work well, but 2 fails. Is there some limitation of the 
> Python bindings regarding NetCDF? The script runs fine if i replace 
> the NetCDF with a Geotiff file.
>
> Any help would be appreciated.
>
> An example NetCDF i used can be found at:
> ftp://hydro1.sci.gsfc.nasa.gov/data/s4pa/WAOB/LPRM_TMI_DY_SOILM3.001/2
> 012/05/ 
> ftp://hydro1.sci.gsfc.nasa.gov/data/s4pa/WAOB/LPRM_TMI_DY_SOILM3.001/2
> 012/05/
>
> Below is the Python script i have used for exploring the issue:
>
> import os
> try:
>    from osgeo import gdal
> except ImportError:
>    import gdal
>
> netcdffile =
> "NETCDF:LPRM-TMI_L3_DY_SOILM3_V001-20120411T144114Z_20120102.nc:soil_moisture_x"
> vrtfile = "LPRM-TMI_L3_DY_SOILM3_V001-20120411T144114Z_20120102.vrt"
> tiffile = "LPRM-TMI_L3_DY_SOILM3_V001-20120411T144114Z_20120102.tif"
>
> # 1: convert the netcdf to vrt externally (works well) 
> os.system('gdal_translate -of "VRT" ' + netcdffile + ' ' + vrtfile)
>
> # 2: try to open the vrt in Python (fails at .ReadAsArray) dsin = 
> gdal.Open(vrtfile)
>
> if not dsin is None:
>  indata = dsin.ReadAsArray(0, 0, dsin.RasterXSize, dsin.RasterYSize)
>
> # 3: convert the same vrt to a tif externally (works well) 
> os.system('gdal_translate ' + vrtfile + ' ' + tiffile)
>
>
> Regards,
> Rutger
>
>
> --
> View this message in context: 
> http://osgeo-org.1560.n6.nabble.com/Reading-a-NetCDF-file-with-python-
> not-recognised-as-a-supported-dataset-name-tp4979943.html
> Sent from the GDAL - Dev mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
_______________________________________________
gdal-dev mailing list
gdal-dev at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list