/** * Acquires a {@link Dataset} and return it, given the name of the Dataset * source and the desired access type * * @param name * of the dataset source to be accessed (usually, a File * name). * @param accessType * @return the acquired {@link Dataset} */ public static Dataset acquireDataSet(final String name,final int accessType) { if (!isGDALAvailable()) { return null; } if(name == null) { throw new IllegalArgumentException("Provided parameter is null:name"); } return gdal.Open(name, accessType); }
/** * Acquires a {@link Dataset} and return it, given the name of the Dataset * source and the desired access type * * @param name * of the dataset source to be accessed (usually, a File * name). * @param accessType * @return the acquired {@link Dataset} */ public static Dataset acquireDataSet(final String name,final int accessType) { if (!isGDALAvailable()) { return null; } if(name == null) { throw new IllegalArgumentException("Provided parameter is null:name"); } return gdal.Open(name, accessType); }
/** * Opens a dataset for the given file in read-only mode. * * @param file the file to open. * @throws IOException if the given file can not be opened. */ public DataSet(final Path file) throws IOException { ds = gdal.Open(file.toString()); if (ds == null) { String msg = gdal.GetLastErrorMsg(); if (msg == null) { msg = "Can not open \"" + file + "\"."; } throw new GDALException(msg); } }
public static Dataset getDataset(final File file, final int mode) { if (isAvailable()) { final String path = file.getAbsolutePath(); if (file.exists()) { final Dataset dataset = gdal.Open(path, mode); if (dataset == null) { throw new GdalException(); } else { final Resource resource = new FileSystemResource(file); setProjectionFromPrjFile(dataset, resource); final long modifiedTime = loadSettings(dataset, resource); // loadAuxXmlFile(modifiedTime); return dataset; } } else { throw new IllegalArgumentException("File no found: " + path); } } else { throw new IllegalStateException("GDAL is not available"); } }
private ImageReader(Path inputFile, int bandIndex, int offsetX, int offsetY, int dataBufferType, int level) { this.dataBufferType = dataBufferType; this.level = level; this.offsetX = offsetX; this.offsetY = offsetY; this.gdalDataset = gdal.Open(inputFile.toString(), gdalconst.GA_ReadOnly); // bands are not 0-base indexed, so we must add 1 Band rasterBand = gdalDataset.GetRasterBand(bandIndex + 1); if (level > 0 && rasterBand.GetOverviewCount() > 0) { this.band = rasterBand.GetOverview(this.level - 1); } else { this.band = rasterBand; } }
/** * Creates a new {@link GdalDataset} from the given file (which must be supported by GDAL). * * @param file * raster image file (format must be supported by GDAL), never <code>null</code> * @param crs * native CRS, can be <code>null</code> (unknown) * @throws UnknownCRSException * @throws IOException */ public GdalDataset( File file, ICRS crs ) throws UnknownCRSException, IOException { this.file = file.getCanonicalFile(); this.crs = crs; dataset = gdal.Open( file.getPath() ); datasetEnvelope = readEnvelope(); width = datasetEnvelope.getSpan0(); height = datasetEnvelope.getSpan1(); datasetPixelsX = dataset.getRasterXSize(); datasetPixelsY = dataset.getRasterYSize(); unitsPerPixelX = width / (double) datasetPixelsX; unitsPerPixelY = height / (double) datasetPixelsY; }
Dataset gdalDataset = gdal.Open(inputFile.toString(), gdalconst.GA_ReadOnly); if (gdalDataset == null) {