NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi list, I have got the netcdf file, which is generated from OIS(DMSP data) by ucar.nc2.FileWriter.writeToFile(). Because the OIS data contain visible and infrared imagery, so the next step I want to extract these two imagery and put them into different geotiff file. I learned that GeotiffWriter can perform this work. But I met some problems in the course of using GeotiffWriter.The following code pieces indicate the error information.////////////////////////////////////////////////////////////////////////////step1: using ucar.nc2.FileWriter to convert OIS into netcdf file//////////////////////////////////////////////////////////////////////////// String datasetIn = "C:/13532264810612.ois"; String datasetOut = "C:/13532264810612.nc"; try { NetcdfFile ncfileIn = ucar.nc2.NetcdfFile.open(datasetIn, null); NetcdfFile ncfileOut = ucar.nc2.FileWriter.writeToFile(ncfileIn, datasetOut, false); ncfileIn.close(); ncfileOut.close(); System.out.println("NetcdfFile written = " + ncfileOut); } catch (Exception e) { e.printStackTrace(); }////////////////////////////////////////////////////////////////////////////////////////step2. Write the infrared information from netcdf to geotiff////////////////////////////////////////////////////////////////////////////////////////writer.writeGrid("C:/13532264810612.nc", "infraredImagery", 0, 0, true, llr);......public void writeGrid(String fileName, String gridName, int time, int level, boolean greyScale, LatLonRect pt) throws IOException { double scaler; GridDataset dataset = ucar.nc2.dt.grid.GridDataset.open(fileName); GridDatatype grid = dataset.findGridDatatype(gridName); GridCoordSystem gcs = grid.getCoordinateSystem(); ProjectionImpl proj = grid.getProjection(); if (grid == null) throw new IllegalArgumentException("No grid named " + gridName + " in fileName"); if (!gcs.isRegularSpatial())//syz The problem! throw new IllegalArgumentException("Must have 1D x and y axes for " + grid.getName());//////////////////////////////////////////////////////////////////////////// The above red code will throw the error info "Must have 1D x and y axes for infraredImagery" The method "boolean isRegularSpatial()" in GridCoordSystem return false.The GridCorrdSystem need both X and Y axes are 1 dimension, but actually, the netcdf is 32 dimension in netccdf, because the longitude and latitude both are decided by the scan line and sample order. I also viewed the "13532264810612.nc" in the NetCDF 2.2 Tools. And the imagery could displayed correctly in the Viewer tab. So I doubt the Dimension information maybe something omitted, and I tried to add the LatitudeDimension and LongitudeDimension to the netcdf file, but it doesn't work. Thanks very much. Any advices is appreciate. Yuanzheng ShaoState Key Lab of Information Engineering in Surveying Mapping and Remote Sensing, Wuhan UniversityAddress:P.O. Box C310, 129 LuoYu Road, Wuhan Hubei, 430079, P.R.China Phone : (086)135-1729-3712 _________________________________________________________________ 怎样买车票更方便?微软春节搜索,第一时间为您提供火车票信息! http://piao.live.com/?form=PANER01
netcdf-java
archives: