public static boolean rewritePointFeatureDataset ( String fileIn , String fileOut , boolean inMemory ) throws IOException { System . out . println ( "Rewrite2 .nc files from " + fileIn + " to " + fileOut + " inMemory= " + inMemory ) ; long start = System . currentTimeMillis ( ) ; // do it in memory for speed NetcdfFile ncfile = inMemory ? NetcdfFile . openInMemory ( fileIn ) : NetcdfFile . open ( fileIn ) ; NetcdfDataset ncd = new NetcdfDataset ( ncfile ) ; Formatter errlog = new Formatter ( ) ; FeatureDataset fd = FeatureDatasetFactoryManager . wrap ( FeatureType . ANY_POINT , ncd , null , errlog ) ; if ( fd == null ) return false ; if ( fd instanceof FeatureDatasetPoint ) { writePointFeatureCollection ( ( FeatureDatasetPoint ) fd , fileOut ) ; fd . close ( ) ; long took = System . currentTimeMillis ( ) - start ; System . out . println ( " that took " + ( took - start ) + " msecs" ) ; return true ; } return false ; }
Open a ucar . nc2 . ft . PointFeatureCollection write out in CF point format .