Package org.geotools.coverage.io.netcdf
Class NetCDFReader
- Object
-
- AbstractGridCoverage2DReader
-
- NetCDFReader
-
- All Implemented Interfaces:
GridCoverageReader
,GridCoverage2DReader
,StructuredGridCoverage2DReader
public class NetCDFReader extends AbstractGridCoverage2DReader implements StructuredGridCoverage2DReader
A NetCDF Reader implementation- Author:
- Daniele Romagnoli, GeoSolutions SAS
-
-
Field Summary
-
Fields inherited from class AbstractGridCoverage2DReader
closeMe, coverageFactory, coverageName, crs, dtLayout, EPS, gzipped, highestRes, hints, inStream, inStreamSPI, numOverviews, offsets, originalEnvelope, originalGridRange, overViewResolutions, raster2Model, scales, source
-
Fields inherited from interface GridCoverage2DReader
ELEVATION_DOMAIN, ELEVATION_DOMAIN_MAXIMUM, ELEVATION_DOMAIN_MINIMUM, ELEVATION_DOMAIN_RESOLUTION, FILE_SOURCE_PROPERTY, HAS_ELEVATION_DOMAIN, HAS_TIME_DOMAIN, MULTICRS_EPSGCODES, MULTICRS_READER, PAM_DATASET, REPROJECTING_READER, SOURCE_URL_PROPERTY, TIME_DOMAIN, TIME_DOMAIN_MAXIMUM, TIME_DOMAIN_MINIMUM, TIME_DOMAIN_RESOLUTION
-
-
Constructor Summary
Constructors Constructor Description NetCDFReader(Object input, Hints uHints)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
createCoverage(String coverageName, SimpleFeatureType schema)
Creates a granule store for a new coverage with the given feature typevoid
delete(boolean deleteData)
delete all stuff (database content, indexer files, property files, associated auxiliary files and so on).void
dispose()
Disposes this reader.CoordinateReferenceSystem
getCoordinateReferenceSystem()
Retrieves theGeneralBounds
for thisAbstractGridCoverage2DReader
.CoordinateReferenceSystem
getCoordinateReferenceSystem(String coverageName)
Retrieves theGeneralBounds
for thisAbstractGridCoverage2DReader
.List<DimensionDescriptor>
getDimensionDescriptors(String coverageName)
Describes the dimensions supported by the specified coverage, if any.Set<ParameterDescriptor<List>>
getDynamicParameters(String coverageName)
Return the set of dynamic parameterDescriptors (the ones related to domains) for this reader.Format
getFormat()
Returns the format handled by thisGridCoverageReader
.GranuleSource
getGranules(String coverageName, boolean readOnly)
Returns the granule source for the specified coverage (might be null, if there is only one supported coverage)int
getGridCoverageCount()
Retrieve the number of coverages contained within the input source.String[]
getGridCoverageNames()
Retrieve the list of coverages contained within the input source.ImageLayout
getImageLayout()
Retrieve theImageLayout
for the default coverage.ImageLayout
getImageLayout(String coverageName)
Retrieve theImageLayout
for the specified coverage.ResourceInfo
getInfo(String coverageName)
Default implementation returns a FileResourceInfo containing same fileGroup list contained in the ServiceInfo object.String[]
getMetadataNames(String coverageName)
Returns the list of metadata keywords associated with a specific gridCoverage referred by name.String
getMetadataValue(String coverageName, String name)
Retrieve the metadata value for a given metadata name for a specified coverage.GeneralBounds
getOriginalEnvelope()
Retrieves theGeneralBounds
for thisAbstractGridCoverage2DReader
.GeneralBounds
getOriginalEnvelope(String coverageName)
Retrieves theGeneralBounds
for thisAbstractGridCoverage2DReader
.GridEnvelope
getOriginalGridRange()
Retrieves theGeneralGridEnvelope
that represents the raster grid dimensions of the highest resolution level in this dataset.GridEnvelope
getOriginalGridRange(String coverageName)
Retrieves theGeneralGridEnvelope
that represents the raster grid dimensions of the highest resolution level in this dataset.MathTransform
getOriginalGridToWorld(String coverageName, PixelInCell pixInCell)
Retrieves the original grid to world transformation for thisAbstractGridCoverage2DReader
.MathTransform
getOriginalGridToWorld(PixelInCell pixInCell)
Retrieves the original grid to world transformation for thisAbstractGridCoverage2DReader
.double[]
getReadingResolutions(String coverageName, OverviewPolicy policy, double[] requestedResolution)
Returns the actual resolution used to read the data given the specified target resolution and the specified overview policydouble[]
getReadingResolutions(OverviewPolicy policy, double[] requestedResolution)
Returns the actual resolution used to read the data given the specified target resolution and the specified overview policydouble[][]
getResolutionLevels()
Retrieve the resolution levels for the default coverage.double[][]
getResolutionLevels(String coverageName)
Retrieve the resolution levels for the specified coverage.List<HarvestedSource>
harvest(String defaultCoverage, Object source, Hints hints)
Harvests the specified source into the reader.boolean
isReadOnly()
Return whether this reader can modify the granule sourceGridCoverage2D
read(String coverageName, GeneralParameterValue[] parameters)
Retrieves theGridEnvelope
associated to the specified coverageName for thisGridCoverage2DReader
.GridCoverage2D
read(GeneralParameterValue[] parameters)
Read a GridCoverage2D base on the specified read parameters.boolean
removeCoverage(String coverageName, boolean forceDelete)
removes a granule store for the specified coverageName-
Methods inherited from class AbstractGridCoverage2DReader
addAllSiblings, addSiblings, checkName, collectScaleOffset, createImageCoverage, createImageCoverage, createImageCoverage, createImageCoverage, decimationOnReadingControl, finalize, getDatasetLayout, getDatasetLayout, getDynamicParameters, getFiles, getGroundControlPoints, getGroundControlPoints, getHighestRes, getHighestRes, getInfo, getMetadataNames, getMetadataValue, getMultiLevelROIProvider, getOverviewGridEnvelope, getOverviewGridEnvelope, getPamDataset, getPamDataset, getRescaledRasterToModel, getResolution, getSibling, getSource, getSourceAsFile, setlayout, setLayout, setReadParams, setReadParams
-
Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface GridCoverage2DReader
getDatasetLayout, getDatasetLayout, getDynamicParameters, getInfo
-
Methods inherited from interface GridCoverageReader
getMetadataNames, getMetadataValue, getSource
-
-
-
-
Constructor Detail
-
NetCDFReader
public NetCDFReader(Object input, Hints uHints) throws DataSourceException
- Throws:
DataSourceException
-
-
Method Detail
-
getFormat
public Format getFormat()
Description copied from interface:GridCoverageReader
Returns the format handled by thisGridCoverageReader
.- Specified by:
getFormat
in interfaceGridCoverageReader
-
getMetadataNames
public String[] getMetadataNames(String coverageName)
Description copied from interface:GridCoverageReader
Returns the list of metadata keywords associated with a specific gridCoverage referred by name. If no metadata is available, the array will be empty.- Specified by:
getMetadataNames
in interfaceGridCoverageReader
- Overrides:
getMetadataNames
in classAbstractGridCoverage2DReader
- Returns:
- The list of metadata keywords for the input source.
-
getMetadataValue
public String getMetadataValue(String coverageName, String name)
Description copied from interface:GridCoverageReader
Retrieve the metadata value for a given metadata name for a specified coverage.- Specified by:
getMetadataValue
in interfaceGridCoverageReader
- Overrides:
getMetadataValue
in classAbstractGridCoverage2DReader
name
- Metadata keyword for which to retrieve metadata.- Returns:
- The metadata value for the given metadata name. Should be one of the name returned by
GridCoverageReader.getMetadataNames()
.
-
getGridCoverageNames
public String[] getGridCoverageNames()
Description copied from interface:GridCoverageReader
Retrieve the list of coverages contained within the input source. Each grid can have a different coordinate system, number of dimensions and grid geometry. For example, a HDF-EOS file (GRID.HDF) contains 6 grid coverages each having a different projection. An empty array will be returned if no sub names exist.- Specified by:
getGridCoverageNames
in interfaceGridCoverageReader
- Overrides:
getGridCoverageNames
in classAbstractGridCoverage2DReader
- Returns:
- The list of grid coverages contained within the input source.
-
getDynamicParameters
public Set<ParameterDescriptor<List>> getDynamicParameters(String coverageName) throws IOException
Description copied from class:AbstractGridCoverage2DReader
Return the set of dynamic parameterDescriptors (the ones related to domains) for this reader. Default implementation returns an empty set of parameters- Specified by:
getDynamicParameters
in interfaceGridCoverage2DReader
- Overrides:
getDynamicParameters
in classAbstractGridCoverage2DReader
- Parameters:
coverageName
- the name of the coverage to work with- Returns:
- the
Set
of dynamic read parameters supported by thisGridCoverage2DReader
. - Throws:
IOException
- in case an error occurs while creating theSet
of dynamic parameters.
-
getGridCoverageCount
public int getGridCoverageCount()
Description copied from interface:GridCoverageReader
Retrieve the number of coverages contained within the input source.- Specified by:
getGridCoverageCount
in interfaceGridCoverageReader
- Overrides:
getGridCoverageCount
in classAbstractGridCoverage2DReader
- Returns:
- The number of coverages contained within the input source.
- See Also:
GridCoverageReader.getGridCoverageCount()
-
read
public GridCoverage2D read(String coverageName, GeneralParameterValue[] parameters) throws IllegalArgumentException, IOException
Description copied from interface:GridCoverage2DReader
Retrieves theGridEnvelope
associated to the specified coverageName for thisGridCoverage2DReader
.- Specified by:
read
in interfaceGridCoverage2DReader
- Specified by:
read
in interfaceGridCoverageReader
- Overrides:
read
in classAbstractGridCoverage2DReader
- Parameters:
coverageName
- the name of the coverage to work withparameters
- an array ofGeneralParameterValue
that uses a subset of the available read params for thisGridCoverage2DReader
as specified by theFormat
- Returns:
- a
GridCoverage2D
for the underlying default coverage for thisGridCoverage2DReader
ornull
in case noGridCoverage2D
can be read for the provided parameters. - Throws:
IllegalArgumentException
- if the specified coverageName does not existIOException
- if a read operation failed for some other input/output reason, includingFileNotFoundException
if no file with the givenname
can be found, orIIOException
if an error was thrown by the underlying image library.
-
read
public GridCoverage2D read(GeneralParameterValue[] parameters) throws IllegalArgumentException, IOException
Read a GridCoverage2D base on the specified read parameters.- Specified by:
read
in interfaceGridCoverage2DReader
- Specified by:
read
in interfaceGridCoverageReader
- Specified by:
read
in classAbstractGridCoverage2DReader
- Parameters:
parameters
- Optional parameters matchingFormat.getReadParameters()
.- Returns:
- a grid coverage from the input source.
- Throws:
InvalidParameterNameException
- if a parameter inparameters
doesn't have a recognized name.InvalidParameterValueException
- if a parameter inparameters
doesn't have a valid value.ParameterNotFoundException
- if a parameter was required for the operation but was not provided in theparameters
list.IOException
- if a read operation failed for some other input/output reason, includingFileNotFoundException
if no file with the givenname
can be found, orIIOException
if an error was thrown by the underlying image library.IllegalArgumentException
-
dispose
public void dispose()
Description copied from class:AbstractGridCoverage2DReader
Disposes this reader.This method just tries to close the underlying
ImageInputStream
.- Specified by:
dispose
in interfaceGridCoverageReader
- Overrides:
dispose
in classAbstractGridCoverage2DReader
-
getOriginalEnvelope
public GeneralBounds getOriginalEnvelope()
Description copied from class:AbstractGridCoverage2DReader
Retrieves theGeneralBounds
for thisAbstractGridCoverage2DReader
.- Specified by:
getOriginalEnvelope
in interfaceGridCoverage2DReader
- Overrides:
getOriginalEnvelope
in classAbstractGridCoverage2DReader
- Returns:
- the
GeneralBounds
for thisAbstractGridCoverage2DReader
.
-
getOriginalEnvelope
public GeneralBounds getOriginalEnvelope(String coverageName)
Description copied from class:AbstractGridCoverage2DReader
Retrieves theGeneralBounds
for thisAbstractGridCoverage2DReader
.- Specified by:
getOriginalEnvelope
in interfaceGridCoverage2DReader
- Overrides:
getOriginalEnvelope
in classAbstractGridCoverage2DReader
- Parameters:
coverageName
- the name of the coverage to work on.- Returns:
- the
GeneralBounds
for thisAbstractGridCoverage2DReader
.
-
getOriginalGridRange
public GridEnvelope getOriginalGridRange()
Description copied from class:AbstractGridCoverage2DReader
Retrieves theGeneralGridEnvelope
that represents the raster grid dimensions of the highest resolution level in this dataset.- Specified by:
getOriginalGridRange
in interfaceGridCoverage2DReader
- Overrides:
getOriginalGridRange
in classAbstractGridCoverage2DReader
- Returns:
- the
GeneralGridEnvelope
that represents the raster grid dimensions of the highest resolution level in this dataset.
-
getOriginalGridRange
public GridEnvelope getOriginalGridRange(String coverageName)
Description copied from class:AbstractGridCoverage2DReader
Retrieves theGeneralGridEnvelope
that represents the raster grid dimensions of the highest resolution level in this dataset.- Specified by:
getOriginalGridRange
in interfaceGridCoverage2DReader
- Overrides:
getOriginalGridRange
in classAbstractGridCoverage2DReader
- Parameters:
coverageName
- the name of the coverage to work with- Returns:
- the
GeneralGridEnvelope
that represents the raster grid dimensions of the highest resolution level in this dataset.
-
getReadingResolutions
public double[] getReadingResolutions(OverviewPolicy policy, double[] requestedResolution)
Description copied from class:AbstractGridCoverage2DReader
Returns the actual resolution used to read the data given the specified target resolution and the specified overview policy- Specified by:
getReadingResolutions
in interfaceGridCoverage2DReader
- Overrides:
getReadingResolutions
in classAbstractGridCoverage2DReader
- Parameters:
policy
- theOverviewPolicy
to use during evaluation.requestedResolution
- the requested resolution- Returns:
- an array of 2 double with the resolution of the selected overview.
-
getReadingResolutions
public double[] getReadingResolutions(String coverageName, OverviewPolicy policy, double[] requestedResolution) throws IOException
Description copied from class:AbstractGridCoverage2DReader
Returns the actual resolution used to read the data given the specified target resolution and the specified overview policy- Specified by:
getReadingResolutions
in interfaceGridCoverage2DReader
- Overrides:
getReadingResolutions
in classAbstractGridCoverage2DReader
- Parameters:
coverageName
- the name of the coverage to work on.policy
- theOverviewPolicy
to use during evaluation.requestedResolution
- the requested resolution- Returns:
- an array of 2 double with the resolution of the selected overview.
- Throws:
IOException
- in case an error occurs.
-
getResolutionLevels
public double[][] getResolutionLevels() throws IOException
Description copied from interface:GridCoverage2DReader
Retrieve the resolution levels for the default coverage.Throw an
IllegalArgumentException
in case the name is wrong and/or no such a coverage exists.- Specified by:
getResolutionLevels
in interfaceGridCoverage2DReader
- Overrides:
getResolutionLevels
in classAbstractGridCoverage2DReader
- Returns:
- the resolution levels for the default coverage.
- Throws:
IOException
-
getResolutionLevels
public double[][] getResolutionLevels(String coverageName) throws IOException
Description copied from interface:GridCoverage2DReader
Retrieve the resolution levels for the specified coverage.Throw an
IllegalArgumentException
in case the name is wrong and/or no such a coverage exists.- Specified by:
getResolutionLevels
in interfaceGridCoverage2DReader
- Overrides:
getResolutionLevels
in classAbstractGridCoverage2DReader
- Parameters:
coverageName
- the name of the coverage for which we want to know the resolution levels.- Returns:
- the resolution levels for the specified coverage.
- Throws:
IOException
-
getImageLayout
public ImageLayout getImageLayout() throws IOException
Description copied from interface:GridCoverage2DReader
Retrieve theImageLayout
for the default coverage.Throw an
IllegalArgumentException
in case the name is wrong and/or no such a coverage exists.- Specified by:
getImageLayout
in interfaceGridCoverage2DReader
- Overrides:
getImageLayout
in classAbstractGridCoverage2DReader
- Returns:
- an
ImageLayout
that is useful for actually knowing theColorModel
, theSampleModel
as well as the tile grid for the default coverage. - Throws:
IOException
-
getImageLayout
public ImageLayout getImageLayout(String coverageName) throws IOException
Description copied from interface:GridCoverage2DReader
Retrieve theImageLayout
for the specified coverage.Throw an
IllegalArgumentException
in case the name is wrong and/or no such a coverage exists.- Specified by:
getImageLayout
in interfaceGridCoverage2DReader
- Overrides:
getImageLayout
in classAbstractGridCoverage2DReader
- Parameters:
coverageName
- the name of the coverage for which we want to know theGridEnvelope
.- Returns:
- an
ImageLayout
that is useful for actually knowing theColorModel
, theSampleModel
as well as the tile grid for a certain coverage. - Throws:
IOException
-
getCoordinateReferenceSystem
public CoordinateReferenceSystem getCoordinateReferenceSystem()
Description copied from class:AbstractGridCoverage2DReader
Retrieves theGeneralBounds
for thisAbstractGridCoverage2DReader
.- Specified by:
getCoordinateReferenceSystem
in interfaceGridCoverage2DReader
- Overrides:
getCoordinateReferenceSystem
in classAbstractGridCoverage2DReader
- Returns:
- the
GeneralBounds
for thisAbstractGridCoverage2DReader
.
-
getCoordinateReferenceSystem
public CoordinateReferenceSystem getCoordinateReferenceSystem(String coverageName)
Description copied from class:AbstractGridCoverage2DReader
Retrieves theGeneralBounds
for thisAbstractGridCoverage2DReader
.- Specified by:
getCoordinateReferenceSystem
in interfaceGridCoverage2DReader
- Overrides:
getCoordinateReferenceSystem
in classAbstractGridCoverage2DReader
- Returns:
- the
GeneralBounds
for thisAbstractGridCoverage2DReader
.
-
getOriginalGridToWorld
public MathTransform getOriginalGridToWorld(PixelInCell pixInCell)
Description copied from class:AbstractGridCoverage2DReader
Retrieves the original grid to world transformation for thisAbstractGridCoverage2DReader
.- Specified by:
getOriginalGridToWorld
in interfaceGridCoverage2DReader
- Overrides:
getOriginalGridToWorld
in classAbstractGridCoverage2DReader
- Parameters:
pixInCell
- specifies the datum of the transformation we want.- Returns:
- the original grid to world transformation for this
AbstractGridCoverage2DReader
.
-
getOriginalGridToWorld
public MathTransform getOriginalGridToWorld(String coverageName, PixelInCell pixInCell)
Description copied from class:AbstractGridCoverage2DReader
Retrieves the original grid to world transformation for thisAbstractGridCoverage2DReader
.- Specified by:
getOriginalGridToWorld
in interfaceGridCoverage2DReader
- Overrides:
getOriginalGridToWorld
in classAbstractGridCoverage2DReader
- Parameters:
coverageName
- the name of the coverage to work withpixInCell
- specifies the datum of the transformation we want.- Returns:
- the original grid to world transformation for this
AbstractGridCoverage2DReader
.
-
getGranules
public GranuleSource getGranules(String coverageName, boolean readOnly) throws IOException, UnsupportedOperationException
Description copied from interface:StructuredGridCoverage2DReader
Returns the granule source for the specified coverage (might be null, if there is only one supported coverage)- Specified by:
getGranules
in interfaceStructuredGridCoverage2DReader
- Parameters:
coverageName
- the name of the specified coveragereadOnly
- a boolean indicating whether we may want modify the GranuleSource- Returns:
- the requested
GranuleSource
- Throws:
IOException
UnsupportedOperationException
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:StructuredGridCoverage2DReader
Return whether this reader can modify the granule source- Specified by:
isReadOnly
in interfaceStructuredGridCoverage2DReader
-
createCoverage
public void createCoverage(String coverageName, SimpleFeatureType schema) throws IOException, UnsupportedOperationException
Description copied from interface:StructuredGridCoverage2DReader
Creates a granule store for a new coverage with the given feature type- Specified by:
createCoverage
in interfaceStructuredGridCoverage2DReader
- Throws:
IOException
UnsupportedOperationException
-
harvest
public List<HarvestedSource> harvest(String defaultCoverage, Object source, Hints hints) throws IOException, UnsupportedOperationException
Description copied from interface:StructuredGridCoverage2DReader
Harvests the specified source into the reader. Depending on the implementation, the original source is harvested in place (e.g., image mosaic), or might be copied into the reader persistent storage (e.g., database raster handling)- Specified by:
harvest
in interfaceStructuredGridCoverage2DReader
- Parameters:
defaultCoverage
- Default target coverage, to be used in case the sources being harvested are not structured ones. The parameter is optional, in case it's missing the reader will use the first coverage as the default target.source
- The source can be any kind of object, it's up to the reader implementation to understand and use it. Commons source types could be a single file, or a folder.hints
- Used to provide implementation specific hints on how to harvest the sources- Throws:
IOException
UnsupportedOperationException
-
getDimensionDescriptors
public List<DimensionDescriptor> getDimensionDescriptors(String coverageName) throws IOException
Description copied from interface:StructuredGridCoverage2DReader
Describes the dimensions supported by the specified coverage, if any. (coverageName might be null, if there is only one supported coverage)- Specified by:
getDimensionDescriptors
in interfaceStructuredGridCoverage2DReader
- Throws:
IOException
-
removeCoverage
public boolean removeCoverage(String coverageName, boolean forceDelete) throws IOException, UnsupportedOperationException
Description copied from interface:StructuredGridCoverage2DReader
removes a granule store for the specified coverageName- Specified by:
removeCoverage
in interfaceStructuredGridCoverage2DReader
- Throws:
IOException
UnsupportedOperationException
-
delete
public void delete(boolean deleteData) throws IOException
Description copied from interface:StructuredGridCoverage2DReader
delete all stuff (database content, indexer files, property files, associated auxiliary files and so on).- Specified by:
delete
in interfaceStructuredGridCoverage2DReader
- Parameters:
deleteData
- specifies whether data (granules) should be deleted too.- Throws:
IOException
-
getInfo
public ResourceInfo getInfo(String coverageName)
Description copied from class:AbstractGridCoverage2DReader
Default implementation returns a FileResourceInfo containing same fileGroup list contained in the ServiceInfo object.- Specified by:
getInfo
in interfaceGridCoverage2DReader
- Overrides:
getInfo
in classAbstractGridCoverage2DReader
- Returns:
- ResourceInfo describing a specific coverage.
-
-