[geotk] Trouble reading GMT grid file
Brian Schlining
bschlining at gmail.com
Thu Nov 3 12:55:05 EDT 2011
Hi Martin et al,
I'm trying to read a GMT grid file and generate a png image of it. First off, I'm having issues reading the grid with geotoolkit. The code I'm trying is:
#!/usr/bin/env groovy
/*
Use as: maplot.groovy <url or file>
@author Brian Schlining
*/
@Grapes([
@GrabResolver(name='geotk', root='http://maven.geotoolkit.org/'),
@GrabConfig(systemClassLoader=true),
@Grab(group = "org.geotoolkit", module = "geotk-referencing", version="3.19"),
@Grab(group = "org.geotoolkit", module = "geotk-coverage", version="3.19"),
@Grab(group = "org.geotoolkit", module = "geotk-coverageio", version="3.19"),
@Grab(group = "org.geotoolkit", module = "geotk-coverageio-netcdf", version="3.19")
])
import org.geotoolkit.coverage.io.CoverageIO
def gridCoverage = CoverageIO.read(args[0])
When I run it as using a file with the default .grd extension, everything barfs because it doesn't recognize the file type. So some SPI somewhere should probably be registered to recognized the '.grd' extension. Anyway, I get the following:
maplot.groovy ~/Downloads/GreaterMontereyBay_UTM10N_50m.grd
Caught: org.geotoolkit.coverage.io.CoverageStoreException: Can?t read file ?GreaterMontereyBay_UTM10N_50m.grd?.
No suitable image reader for this input.
org.geotoolkit.coverage.io.CoverageStoreException: Can?t read file ?GreaterMontereyBay_UTM10N_50m.grd?.
No suitable image reader for this input.
at org.geotoolkit.coverage.io.ImageCoverageReader.setInput(ImageCoverageReader.java:401)
at org.geotoolkit.coverage.io.CoverageIO.createSimpleReader(CoverageIO.java:129)
at org.geotoolkit.coverage.io.CoverageIO.read(CoverageIO.java:73)
at org.geotoolkit.coverage.io.CoverageIO$read.call(Unknown Source)
at maplot.run(maplot.groovy:19)
Caused by: org.geotoolkit.image.io.UnsupportedImageFormatException: No suitable image reader for this input.
at org.geotoolkit.image.io.XImageIO.getReader(XImageIO.java:357)
at org.geotoolkit.image.io.XImageIO.getReaderBySuffix(XImageIO.java:498)
at org.geotoolkit.image.io.XImageIO.getReaderBySuffix(XImageIO.java:473)
at org.geotoolkit.coverage.io.ImageCoverageReader.createImageReader(ImageCoverageReader.java:456)
at org.geotoolkit.coverage.io.ImageCoverageReader.setInput(ImageCoverageReader.java:335)
... 4 more
If I change the files extension to .nc, I get the following exception:
maplot.groovy ~/Downloads/GreaterMontereyBay_UTM10N_50m.nc
Caught: java.lang.NoSuchMethodError: ucar.nc2.VariableIF.getName()Ljava/lang/String;
java.lang.NoSuchMethodError: ucar.nc2.VariableIF.getName()Ljava/lang/String;
at org.geotoolkit.image.io.plugin.NetcdfImageReader.isAxis(NetcdfImageReader.java:833)
at org.geotoolkit.image.io.plugin.NetcdfImageReader.getVariableNames(NetcdfImageReader.java:935)
at org.geotoolkit.image.io.plugin.NetcdfImageReader.getImageNames(NetcdfImageReader.java:424)
at org.geotoolkit.image.io.plugin.NetcdfImageReader.getNumImages(NetcdfImageReader.java:481)
at org.geotoolkit.image.io.SpatialImageReader.checkImageIndex(SpatialImageReader.java:186)
at org.geotoolkit.image.io.plugin.NetcdfImageReader.prepareVariable(NetcdfImageReader.java:970)
at org.geotoolkit.image.io.plugin.NetcdfImageReader.getWidth(NetcdfImageReader.java:565)
at org.geotoolkit.coverage.io.ImageCoverageReader.getGridGeometry(ImageCoverageReader.java:575)
at org.geotoolkit.coverage.io.ImageCoverageReader.read(ImageCoverageReader.java:861)
at org.geotoolkit.coverage.io.ImageCoverageReader.read(ImageCoverageReader.java:128)
at org.geotoolkit.coverage.io.CoverageIO.read(CoverageIO.java:75)
at org.geotoolkit.coverage.io.CoverageIO$read.call(Unknown Source)
at maplot.run(maplot.groovy:19)
The CDL for the file in question is:
netcdf GreaterMontereyBay_UTM10N_50m {
dimensions:
x = 5083 ;
y = 4067 ;
variables:
double x(x) ;
x:long_name = "Easting (meters)" ;
x:actual_range = 422985.277598382, 677085.277598383 ;
double y(y) ;
y:long_name = "Northing (meters)" ;
y:actual_range = 3915514.90677777, 4118814.90677777 ;
float z(y, x) ;
z:long_name = "Topography (m)" ;
z:actual_range = -4032.438f, 964.f ;
// global attributes:
:Conventions = "COARDS/CF-1.0" ;
:description = "\tProjection: UTM10N\n",
"\tGrid created by: GMTGridWriter.scala" ;
:CreationDate = "20110214T194207Z" ;
}
Any suggestions? Thanks in advance!--
Brian Schlining
More information about the Geotoolkit
mailing list