Ann, What version of netcdf-java are you using? I made a mistake based on what I thought would happen, but hadn't run your example code. When I run your example, with netcdf-java 4.6.1, your original URL ending in '.nc' works fine for me. There is one problem where I get an exception at line 63 because you are taking a variable from the Opendap dataset and passing it to ncwriter.write() for the local dataset; you can't do that, you need to create a new Variable for the local dataset. Ryan > Hi Ryan, > > I used the URL (String > inputfile="http://convection.meas.ncsu.edu:8080/thredds/dodsC/prism/daily/tmin/PRISM_tmin_stable_4kmD1_20110515.nc.dods";) > that you had provided and unfortunately I got the below error when I try to > open the file using either openDataset() and openFile(). > I had checked and the server is not down. > > opendap.dap.DAP2Exception: HTTP/1.1 404 Not Found: > http://convection.meas.ncsu.edu:8080/thredds/dodsC/prism/daily/tmin/PRISM_tmin_stable_4kmD1_20110515.nc.dods.dds > at opendap.dap.DConnect2.openConnection(DConnect2.java:273) > at opendap.dap.DConnect2.getDDS(DConnect2.java:584) > at opendap.dap.DConnect2.getDDS(DConnect2.java:557) > at ucar.nc2.dods.DODSNetcdfFile.<init>(DODSNetcdfFile.java:241) > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) > at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) > at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) > at java.lang.reflect.Constructor.newInstance(Unknown Source) > at > ucar.nc2.dataset.NetcdfDataset.openDodsByReflection(NetcdfDataset.java:1036) > at ucar.nc2.dataset.NetcdfDataset.acquireDODS(NetcdfDataset.java:986) > at ucar.nc2.dataset.NetcdfDataset.openOrAcquireFile(NetcdfDataset.java:712) > at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:426) > at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:409) > at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:394) > at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:381) > at testzone.Opendapexample.main(Opendapexample.java:47) > > I am not sure how a .dds is getting added to the end of the string. How are > you opening the file to read the contents? > Also I donât want to download the PRISM data. I want to copy the data to > another new netcdffile. > > Thanks for the help! > Ann > > -----Original Message----- > From: Unidata netCDF Java Support [mailto:address@hidden > Sent: Monday, May 11, 2015 5:35 PM > To: Ann Smittu Joseph > Cc: address@hidden > Subject: [netCDFJava #BDR-563250]: Issue reading/writing with OPENDAP > > Ann, > > Thanks for the detailed bug report. In order to read the dataset using > opendap support within NetcdfDataset, the URL needs to end with '.dods'. So > in your case, the URL should be: > > String > inputfile="http://convection.meas.ncsu.edu:8080/thredds/dodsC/prism/daily/tmin/PRISM_tmin_stable_4kmD1_20110515.nc.dods"; > > (This is the same URL as the "Get Binary" button on the Opendap HTML page.) > > Using this new URL, I'm able to download the data. Let me know if that's not > the case for you. > > Ryan > > > Hi, > > > > I have an issue trying to read and write data to netcdf using OPENDAP. > > I am not sure if the issue is at the server or in my code. If I save > > the "PRISM.....nc" in my local system and then use openFile(). The > > program runs fine. > > > > If I try to read the data using OPENDAP url and openFile(), I get the > > error: > > > > Exception in thread "main" java.lang.ClassCastException: > > ucar.nc2.dods.DodsV cannot be cast to > > ucar.nc2.iosp.netcdf3.N3header$Vinfo > > at ucar.nc2.iosp.netcdf3.N3iosp.writeData(N3iosp.java:695) > > at ucar.nc2.NetcdfFileWriter.write(NetcdfFileWriter.java:931) > > at testzone.Opendapexample.main(Opendapexample.java:66) > > > > If I try to read the data using OPENDAP url and openDataset, I get the > > error: > > Exception in thread "main" java.lang.NullPointerException at > > ucar.nc2.iosp.netcdf3.N3iosp.writeData(N3iosp.java:717) > > at ucar.nc2.NetcdfFileWriter.write(NetcdfFileWriter.java:931) > <SNIP> > > > > Ann > > > Ticket Details > =================== > Ticket ID: BDR-563250 > Department: Support netCDF Java > Priority: Normal > Status: Closed > > Ticket Details =================== Ticket ID: BDR-563250 Department: Support netCDF Java Priority: Normal Status: Closed
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.