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, sourceFields 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 -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateCoverage(String coverageName, SimpleFeatureType schema) Creates a granule store for a new coverage with the given feature typevoiddelete(boolean deleteData) delete all stuff (database content, indexer files, property files, associated auxiliary files and so on).voiddispose()Disposes this reader.Retrieves theGeneralBoundsfor thisAbstractGridCoverage2DReader.getCoordinateReferenceSystem(String coverageName) Retrieves theGeneralBoundsfor thisAbstractGridCoverage2DReader.getDimensionDescriptors(String coverageName) Describes the dimensions supported by the specified coverage, if any.getDynamicParameters(String coverageName) Return the set of dynamic parameterDescriptors (the ones related to domains) for this reader.Returns the format handled by thisGridCoverageReader.getGranules(String coverageName, boolean readOnly) Returns the granule source for the specified coverage (might be null, if there is only one supported coverage)intRetrieve the number of coverages contained within the input source.String[]Retrieve the list of coverages contained within the input source.ImageLayoutRetrieve theImageLayoutfor the default coverage.ImageLayoutgetImageLayout(String coverageName) Retrieve theImageLayoutfor the specified coverage.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.getMetadataValue(String coverageName, String name) Retrieve the metadata value for a given metadata name for a specified coverage.Retrieves theGeneralBoundsfor thisAbstractGridCoverage2DReader.getOriginalEnvelope(String coverageName) Retrieves theGeneralBoundsfor thisAbstractGridCoverage2DReader.Retrieves theGeneralGridEnvelopethat represents the raster grid dimensions of the highest resolution level in this dataset.getOriginalGridRange(String coverageName) Retrieves theGeneralGridEnvelopethat represents the raster grid dimensions of the highest resolution level in this dataset.getOriginalGridToWorld(String coverageName, PixelInCell pixInCell) Retrieves the original grid to world transformation for thisAbstractGridCoverage2DReader.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[][]Retrieve the resolution levels for the default coverage.double[][]getResolutionLevels(String coverageName) Retrieve the resolution levels for the specified coverage.Harvests the specified source into the reader.booleanReturn whether this reader can modify the granule sourceread(String coverageName, GeneralParameterValue... parameters) Retrieves theGridEnvelopeassociated to the specified coverageName for thisGridCoverage2DReader.read(GeneralParameterValue... parameters) Read a GridCoverage2D base on the specified read parameters.booleanremoveCoverage(String coverageName, boolean forceDelete) removes a granule store for the specified coverageNameMethods 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, setReadParamsMethods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface GridCoverage2DReader
getDatasetLayout, getDatasetLayout, getDynamicParameters, getInfoMethods inherited from interface GridCoverageReader
getMetadataNames, getMetadataValue, getSource
-
Constructor Details
-
NetCDFReader
- Throws:
DataSourceException
-
-
Method Details
-
getFormat
Description copied from interface:GridCoverageReaderReturns the format handled by thisGridCoverageReader.- Specified by:
getFormatin interfaceGridCoverageReader
-
getMetadataNames
Description copied from interface:GridCoverageReaderReturns 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:
getMetadataNamesin interfaceGridCoverageReader- Overrides:
getMetadataNamesin classAbstractGridCoverage2DReader- Returns:
- The list of metadata keywords for the input source.
-
getMetadataValue
Description copied from interface:GridCoverageReaderRetrieve the metadata value for a given metadata name for a specified coverage.- Specified by:
getMetadataValuein interfaceGridCoverageReader- Overrides:
getMetadataValuein classAbstractGridCoverage2DReadername- 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
Description copied from interface:GridCoverageReaderRetrieve 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:
getGridCoverageNamesin interfaceGridCoverageReader- Overrides:
getGridCoverageNamesin classAbstractGridCoverage2DReader- Returns:
- The list of grid coverages contained within the input source.
-
getDynamicParameters
Description copied from class:AbstractGridCoverage2DReaderReturn the set of dynamic parameterDescriptors (the ones related to domains) for this reader. Default implementation returns an empty set of parameters- Specified by:
getDynamicParametersin interfaceGridCoverage2DReader- Overrides:
getDynamicParametersin classAbstractGridCoverage2DReader- Parameters:
coverageName- the name of the coverage to work with- Returns:
- the
Setof dynamic read parameters supported by thisGridCoverage2DReader. - Throws:
IOException- in case an error occurs while creating theSetof dynamic parameters.
-
getGridCoverageCount
public int getGridCoverageCount()Description copied from interface:GridCoverageReaderRetrieve the number of coverages contained within the input source.- Specified by:
getGridCoverageCountin interfaceGridCoverageReader- Overrides:
getGridCoverageCountin classAbstractGridCoverage2DReader- Returns:
- The number of coverages contained within the input source.
- See Also:
-
read
public GridCoverage2D read(String coverageName, GeneralParameterValue... parameters) throws IllegalArgumentException, IOException Description copied from interface:GridCoverage2DReaderRetrieves theGridEnvelopeassociated to the specified coverageName for thisGridCoverage2DReader.- Specified by:
readin interfaceGridCoverage2DReader- Specified by:
readin interfaceGridCoverageReader- Overrides:
readin classAbstractGridCoverage2DReader- Parameters:
coverageName- the name of the coverage to work withparameters- an array ofGeneralParameterValuethat uses a subset of the available read params for thisGridCoverage2DReaderas specified by theFormat- Returns:
- a
GridCoverage2Dfor the underlying default coverage for thisGridCoverage2DReaderornullin case noGridCoverage2Dcan 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, includingFileNotFoundExceptionif no file with the givennamecan be found, orIIOExceptionif 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:
readin interfaceGridCoverage2DReader- Specified by:
readin interfaceGridCoverageReader- Specified by:
readin classAbstractGridCoverage2DReader- Parameters:
parameters- Optional parameters matchingFormat.getReadParameters().- Returns:
- a grid coverage from the input source.
- Throws:
InvalidParameterNameException- if a parameter inparametersdoesn't have a recognized name.InvalidParameterValueException- if a parameter inparametersdoesn't have a valid value.ParameterNotFoundException- if a parameter was required for the operation but was not provided in theparameterslist.IOException- if a read operation failed for some other input/output reason, includingFileNotFoundExceptionif no file with the givennamecan be found, orIIOExceptionif an error was thrown by the underlying image library.IllegalArgumentException
-
dispose
public void dispose()Description copied from class:AbstractGridCoverage2DReaderDisposes this reader.This method just tries to close the underlying
ImageInputStream.- Specified by:
disposein interfaceGridCoverageReader- Overrides:
disposein classAbstractGridCoverage2DReader
-
getOriginalEnvelope
Description copied from class:AbstractGridCoverage2DReaderRetrieves theGeneralBoundsfor thisAbstractGridCoverage2DReader.- Specified by:
getOriginalEnvelopein interfaceGridCoverage2DReader- Overrides:
getOriginalEnvelopein classAbstractGridCoverage2DReader- Returns:
- the
GeneralBoundsfor thisAbstractGridCoverage2DReader.
-
getOriginalEnvelope
Description copied from class:AbstractGridCoverage2DReaderRetrieves theGeneralBoundsfor thisAbstractGridCoverage2DReader.- Specified by:
getOriginalEnvelopein interfaceGridCoverage2DReader- Overrides:
getOriginalEnvelopein classAbstractGridCoverage2DReader- Parameters:
coverageName- the name of the coverage to work on.- Returns:
- the
GeneralBoundsfor thisAbstractGridCoverage2DReader.
-
getOriginalGridRange
Description copied from class:AbstractGridCoverage2DReaderRetrieves theGeneralGridEnvelopethat represents the raster grid dimensions of the highest resolution level in this dataset.- Specified by:
getOriginalGridRangein interfaceGridCoverage2DReader- Overrides:
getOriginalGridRangein classAbstractGridCoverage2DReader- Returns:
- the
GeneralGridEnvelopethat represents the raster grid dimensions of the highest resolution level in this dataset.
-
getOriginalGridRange
Description copied from class:AbstractGridCoverage2DReaderRetrieves theGeneralGridEnvelopethat represents the raster grid dimensions of the highest resolution level in this dataset.- Specified by:
getOriginalGridRangein interfaceGridCoverage2DReader- Overrides:
getOriginalGridRangein classAbstractGridCoverage2DReader- Parameters:
coverageName- the name of the coverage to work with- Returns:
- the
GeneralGridEnvelopethat represents the raster grid dimensions of the highest resolution level in this dataset.
-
getReadingResolutions
Description copied from class:AbstractGridCoverage2DReaderReturns the actual resolution used to read the data given the specified target resolution and the specified overview policy- Specified by:
getReadingResolutionsin interfaceGridCoverage2DReader- Overrides:
getReadingResolutionsin classAbstractGridCoverage2DReader- Parameters:
policy- theOverviewPolicyto 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:AbstractGridCoverage2DReaderReturns the actual resolution used to read the data given the specified target resolution and the specified overview policy- Specified by:
getReadingResolutionsin interfaceGridCoverage2DReader- Overrides:
getReadingResolutionsin classAbstractGridCoverage2DReader- Parameters:
coverageName- the name of the coverage to work on.policy- theOverviewPolicyto 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
Description copied from interface:GridCoverage2DReaderRetrieve the resolution levels for the default coverage.Throw an
IllegalArgumentExceptionin case the name is wrong and/or no such a coverage exists.- Specified by:
getResolutionLevelsin interfaceGridCoverage2DReader- Overrides:
getResolutionLevelsin classAbstractGridCoverage2DReader- Returns:
- the resolution levels for the default coverage.
- Throws:
IOException
-
getResolutionLevels
Description copied from interface:GridCoverage2DReaderRetrieve the resolution levels for the specified coverage.Throw an
IllegalArgumentExceptionin case the name is wrong and/or no such a coverage exists.- Specified by:
getResolutionLevelsin interfaceGridCoverage2DReader- Overrides:
getResolutionLevelsin 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
Description copied from interface:GridCoverage2DReaderRetrieve theImageLayoutfor the default coverage.Throw an
IllegalArgumentExceptionin case the name is wrong and/or no such a coverage exists.- Specified by:
getImageLayoutin interfaceGridCoverage2DReader- Overrides:
getImageLayoutin classAbstractGridCoverage2DReader- Returns:
- an
ImageLayoutthat is useful for actually knowing theColorModel, theSampleModelas well as the tile grid for the default coverage. - Throws:
IOException
-
getImageLayout
Description copied from interface:GridCoverage2DReaderRetrieve theImageLayoutfor the specified coverage.Throw an
IllegalArgumentExceptionin case the name is wrong and/or no such a coverage exists.- Specified by:
getImageLayoutin interfaceGridCoverage2DReader- Overrides:
getImageLayoutin classAbstractGridCoverage2DReader- Parameters:
coverageName- the name of the coverage for which we want to know theGridEnvelope.- Returns:
- an
ImageLayoutthat is useful for actually knowing theColorModel, theSampleModelas well as the tile grid for a certain coverage. - Throws:
IOException
-
getCoordinateReferenceSystem
Description copied from class:AbstractGridCoverage2DReaderRetrieves theGeneralBoundsfor thisAbstractGridCoverage2DReader.- Specified by:
getCoordinateReferenceSystemin interfaceGridCoverage2DReader- Overrides:
getCoordinateReferenceSystemin classAbstractGridCoverage2DReader- Returns:
- the
GeneralBoundsfor thisAbstractGridCoverage2DReader.
-
getCoordinateReferenceSystem
Description copied from class:AbstractGridCoverage2DReaderRetrieves theGeneralBoundsfor thisAbstractGridCoverage2DReader.- Specified by:
getCoordinateReferenceSystemin interfaceGridCoverage2DReader- Overrides:
getCoordinateReferenceSystemin classAbstractGridCoverage2DReader- Returns:
- the
GeneralBoundsfor thisAbstractGridCoverage2DReader.
-
getOriginalGridToWorld
Description copied from class:AbstractGridCoverage2DReaderRetrieves the original grid to world transformation for thisAbstractGridCoverage2DReader.- Specified by:
getOriginalGridToWorldin interfaceGridCoverage2DReader- Overrides:
getOriginalGridToWorldin classAbstractGridCoverage2DReader- Parameters:
pixInCell- specifies the datum of the transformation we want.- Returns:
- the original grid to world transformation for this
AbstractGridCoverage2DReader.
-
getOriginalGridToWorld
Description copied from class:AbstractGridCoverage2DReaderRetrieves the original grid to world transformation for thisAbstractGridCoverage2DReader.- Specified by:
getOriginalGridToWorldin interfaceGridCoverage2DReader- Overrides:
getOriginalGridToWorldin 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:StructuredGridCoverage2DReaderReturns the granule source for the specified coverage (might be null, if there is only one supported coverage)- Specified by:
getGranulesin interfaceStructuredGridCoverage2DReader- Parameters:
coverageName- the name of the specified coveragereadOnly- a boolean indicating whether we may want modify the GranuleSource- Returns:
- the requested
GranuleSource - Throws:
IOExceptionUnsupportedOperationException
-
isReadOnly
public boolean isReadOnly()Description copied from interface:StructuredGridCoverage2DReaderReturn whether this reader can modify the granule source- Specified by:
isReadOnlyin interfaceStructuredGridCoverage2DReader
-
createCoverage
public void createCoverage(String coverageName, SimpleFeatureType schema) throws IOException, UnsupportedOperationException Description copied from interface:StructuredGridCoverage2DReaderCreates a granule store for a new coverage with the given feature type- Specified by:
createCoveragein interfaceStructuredGridCoverage2DReader- Throws:
IOExceptionUnsupportedOperationException
-
harvest
public List<HarvestedSource> harvest(String defaultCoverage, Object source, Hints hints) throws IOException, UnsupportedOperationException Description copied from interface:StructuredGridCoverage2DReaderHarvests 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:
harvestin 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:
IOExceptionUnsupportedOperationException
-
getDimensionDescriptors
Description copied from interface:StructuredGridCoverage2DReaderDescribes the dimensions supported by the specified coverage, if any. (coverageName might be null, if there is only one supported coverage)- Specified by:
getDimensionDescriptorsin interfaceStructuredGridCoverage2DReader- Throws:
IOException
-
removeCoverage
public boolean removeCoverage(String coverageName, boolean forceDelete) throws IOException, UnsupportedOperationException Description copied from interface:StructuredGridCoverage2DReaderremoves a granule store for the specified coverageName- Specified by:
removeCoveragein interfaceStructuredGridCoverage2DReader- Throws:
IOExceptionUnsupportedOperationException
-
delete
Description copied from interface:StructuredGridCoverage2DReaderdelete all stuff (database content, indexer files, property files, associated auxiliary files and so on).- Specified by:
deletein interfaceStructuredGridCoverage2DReader- Parameters:
deleteData- specifies whether data (granules) should be deleted too.- Throws:
IOException
-
getInfo
Description copied from class:AbstractGridCoverage2DReaderDefault implementation returns a FileResourceInfo containing same fileGroup list contained in the ServiceInfo object.- Specified by:
getInfoin interfaceGridCoverage2DReader- Overrides:
getInfoin classAbstractGridCoverage2DReader- Returns:
- ResourceInfo describing a specific coverage.
-