[geotk] Error while reading netCDF file
Hendy Sumanto
hsumanto at vpac.org
Mon Aug 22 07:18:34 EDT 2011
Reading NetCDF resulted in the below error.
Any idea how to fix this issue?
Thank you.
Regards,
Hendy
Exception in thread "main" org.geotoolkit.coverage.io.CoverageStoreException: Can’t read file “dem20_r500_3112.nc”.
Parameter “origin” is missing.
at org.geotoolkit.coverage.io.ImageCoverageReader.getGridGeometry(ImageCoverageReader.java:588)
at org.geotoolkit.coverage.io.ImageCoverageReader.read(ImageCoverageReader.java:860)
at org.vpac.geotk.CoordinateConversion.resampleNetcdf(CoordinateConversion.java:197)
at org.vpac.geotk.CoordinateConversion.main(CoordinateConversion.java:267)
Caused by: org.geotoolkit.image.io.ImageMetadataException: Parameter “origin” is missing.
at org.geotoolkit.image.io.metadata.MetadataHelper.ensureMetadataExists(MetadataHelper.java:168)
at org.geotoolkit.image.io.metadata.MetadataHelper.getGridToCRS(MetadataHelper.java:328)
at org.geotoolkit.coverage.io.ImageCoverageReader.getGridGeometry(ImageCoverageReader.java:580)
... 3 more
These are my source code
public static void resampleNetcdf() throws CoverageStoreException, NoSuchAuthorityCodeException, FactoryException {
CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326");
ImageCoverageReader reader = new ImageCoverageReader();
// reader.setInput(new File("cldc.mean.nc"));
reader.setInput(new File("dem20_r500_3112.nc"));
GridCoverage coverage = reader.read(0, null);
// SpatialMetadata metadata = reader.getCoverageMetadata(0);
// System.out.println(metadata);
// GridGeometry2D gridGeometry = reader.getGridGeometry(0);
// System.out.println(gridGeometry);
reader.dispose();
// GridCoverage resultCvg = (GridCoverage) Operations.DEFAULT.resample(coverage, targetCRS);
// GridCoverageWriteParam param = new GridCoverageWriteParam();
// param.setFormatName("geotiff");
// ImageCoverageWriter writer = new ImageCoverageWriter();
// writer.setOutput(new File("dem20_r500_3112-out.tif"));
// writer.write(resultCvg, param);
// writer.dispose();
}
/**
* Runs the demo from the command line.
*
*/
public static void main(String[] args) throws FactoryException, TransformException, CoverageStoreException {
IIORegistry registry = IIORegistry.getDefaultInstance();
registry.registerServiceProvider(new TIFFImageReaderSpi(), ImageReaderSpi.class);
registry.registerServiceProvider(new GeoTiffImageReader.Spi("TIFF"), ImageReaderSpi.class);
registry.registerServiceProvider(new NetcdfImageReader.Spi(), ImageReaderSpi.class);
registry.registerServiceProvider(new GeoTiffImageWriter.Spi("TIFF"), ImageWriterSpi.class);
// resampleGeotiff();
resampleNetcdf();
System.out.println("Finished...");
These are the gdalinfo of the netCDF file (I produced this netCDF file by translating a LANDSAT geotiff into netCDF using gdal_translate):
hsumanto at uladev ~ $ gdalinfo dem20_r500_3112.nc
Driver: netCDF/Network Common Data Format
Files: dem20_r500_3112.nc
dem20_r500_3112.nc.aux.xml
Size is 1838, 1317
Coordinate System is:
PROJCS["GDA94 / Geoscience Australia Lambert",
GEOGCS["GDA94",
DATUM["Geocentric_Datum_of_Australia_1994",
SPHEROID["GRS 1980",6378137,298.2572221010002,
AUTHORITY["EPSG","7019"]],
AUTHORITY["EPSG","6283"]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433],
AUTHORITY["EPSG","4283"]],
PROJECTION["Lambert_Conformal_Conic_2SP"],
PARAMETER["standard_parallel_1",-18],
PARAMETER["standard_parallel_2",-36],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",134],
PARAMETER["false_easting",0],
PARAMETER["false_northing",0],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
AUTHORITY["EPSG","3112"]]
Origin = (539144.000000000000000,-3825710.000000000000000)
Pixel Size = (500.000000000000000,-500.000000000000000)
Metadata:
NC_GLOBAL#Conventions=CF-1.0
Band1#_FillValue=-1.000000e+10
Band1#grid_mapping=lambert_conformal_conic
Band1#long_name=GDAL Band Number 1
lambert_conformal_conic#Northernmost_Northing=-3.82571e+06
lambert_conformal_conic#Southernmost_Northing=-4.48421e+06
lambert_conformal_conic#Easternmost_Easting=1.45814e+06
lambert_conformal_conic#Westernmost_Easting=539144
lambert_conformal_conic#spatial_ref=PROJCS["GDA94 / Geoscience Australia Lambert",GEOGCS["GDA94",DATUM["Geocentric_Datum_of_Australia_1994",SPHEROID["GRS 1980",6378137,298.2572221010002,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6283"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4283"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",-18],PARAMETER["standard_parallel_2",-36],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",134],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","3112"]]
lambert_conformal_conic#GeoTransform=539144 500 0 -3.82571e+06 0 -500
lambert_conformal_conic#grid_mapping_name=lambert_conformal_conic
lambert_conformal_conic#standard_parallel_1=-1.800000e+01
lambert_conformal_conic#standard_parallel_2=-3.600000e+01
lambert_conformal_conic#latitude_of_projection_origin=0.000000e+00
lambert_conformal_conic#longitude_of_central_meridian=1.340000e+02
lambert_conformal_conic#false_easting=0.000000e+00
lambert_conformal_conic#false_northing=0.000000e+00
AREA_OR_POINT=Area
Corner Coordinates:
Upper Left ( 539144.000,-3825710.000) (139d51'32.69"E, 33d51'18.49"S)
Lower Left ( 539144.000,-4484210.000) (140d12'45.27"E, 39d45'53.29"S)
Upper Right ( 1458144.000,-3825710.000) (149d46'27.56"E, 33d 8'16.73"S)
Lower Right ( 1458144.000,-4484210.000) (150d42'59.94"E, 39d 1' 7.55"S)
Center ( 998644.000,-4154960.000) (145d 8'58.86"E, 36d32'31.58"S)
Band 1 Block=1838x1 Type=Float32, ColorInterp=Gray
NoData Value=-10000000000
Metadata:
NETCDF_VARNAME=Band1
--
Hendy Sumanto
Software Developer
Victorian Partnership for Advanced Computing (VPAC)
Innovation Powered by Advanced Computing
http://www.vpac.org
t: +61 3 9020 0191 (TC)
t: +61 3 9647 5437 (FB)
f: +61 3 9646 7787
More information about the Geotoolkit
mailing list