本文整理汇总了Java中org.geotools.coverage.grid.io.AbstractGridFormat.getReader方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractGridFormat.getReader方法的具体用法?Java AbstractGridFormat.getReader怎么用?Java AbstractGridFormat.getReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.coverage.grid.io.AbstractGridFormat
的用法示例。
在下文中一共展示了AbstractGridFormat.getReader方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.geotools.coverage.grid.io.AbstractGridFormat; //导入方法依赖的package包/类
@Override
public void run() {
final Display display = WorkbenchHelper.getDisplay();
final Shell shell = new Shell(display);
final File openFile = JFileImageChooser.showOpenFile(shell);
if (openFile != null && openFile.exists()) {
final AbstractGridFormat format = GridFormatFinder.findFormat(openFile);
final AbstractGridCoverage2DReader tiffReader = format.getReader(openFile);
final StyleFactoryImpl sf = new StyleFactoryImpl();
final RasterSymbolizer symbolizer = sf.getDefaultRasterSymbolizer();
final Style defaultStyle = SLD.wrapSymbolizers(symbolizer);
final MapContent mapContent = mapPane.getMapContent();
final Layer layer = new GridReaderLayer(tiffReader, defaultStyle);
layer.setTitle(openFile.getName());
mapContent.addLayer(layer);
mapPane.redraw();
}
}
示例2: getRenderer
import org.geotools.coverage.grid.io.AbstractGridFormat; //导入方法依赖的package包/类
private static GTRenderer getRenderer( File rasterFile ) {
AbstractGridFormat format = GridFormatFinder.findFormat(rasterFile);
AbstractGridCoverage2DReader coverageReader = format.getReader(rasterFile);
MapContent mapContent = new MapContent();
try {
Style rasterStyle = SldUtilities.getStyleFromFile(rasterFile);
if (rasterStyle == null) {
RasterSymbolizer sym = SldUtilities.sf.getDefaultRasterSymbolizer();
rasterStyle = SLD.wrapSymbolizers(sym);
}
GridReaderLayer layer = new GridReaderLayer(coverageReader, rasterStyle);
mapContent.addLayer(layer);
mapContent.getViewport().setCoordinateReferenceSystem(CrsUtilities.WGS84);
} catch (Exception e) {
e.printStackTrace();
}
GTRenderer renderer = new StreamingRenderer();
renderer.setMapContent(mapContent);
return renderer;
}
示例3: exampleGridCoverageDirect
import org.geotools.coverage.grid.io.AbstractGridFormat; //导入方法依赖的package包/类
void exampleGridCoverageDirect() throws Exception {
double x =0;
double y = 0;
CoordinateReferenceSystem crs = null;
File file = new File("test.tiff");
AbstractGridFormat format = GridFormatFinder.findFormat(file);
GridCoverage2DReader reader = format.getReader(file);
// exampleGridCoverageDirect start
GridCoverage2D coverage = reader.read(null);
// direct access
DirectPosition position = new DirectPosition2D( crs, x, y);
double[] sample = (double[]) coverage.evaluate( position ); // assume double
// resample with the same array
sample = coverage.evaluate( position, sample );
// exampleGridCoverageDirect end
}
示例4: main
import org.geotools.coverage.grid.io.AbstractGridFormat; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
String ctp = "/home/hydrologis/data/CTP/trentino_ctp/ctp.shp";
File file = new File(ctp);
AbstractGridFormat format = GridFormatFinder.findFormat(file);
AbstractGridCoverage2DReader reader = format.getReader(file);
BufferedImage image = MBTilesHelper.readGridcoverageImageForTile(reader, 1, 1, 19, null);
}
示例5: exampleGridFormat
import org.geotools.coverage.grid.io.AbstractGridFormat; //导入方法依赖的package包/类
@SuppressWarnings("unused")
void exampleGridFormat() throws Exception {
// exampleGridFormat start
File file = new File("test.tiff");
AbstractGridFormat format = GridFormatFinder.findFormat(file);
GridCoverage2DReader reader = format.getReader(file);
GridCoverage2D coverage = reader.read(null);
// exampleGridFormat end
}
示例6: exampleGridCoverageUsing
import org.geotools.coverage.grid.io.AbstractGridFormat; //导入方法依赖的package包/类
@SuppressWarnings("unused")
void exampleGridCoverageUsing() throws Exception {
File file = new File("test.tiff");
AbstractGridFormat format = GridFormatFinder.findFormat(file);
GridCoverage2DReader reader = format.getReader(file);
// exampleGridCoverageUsing start
GridCoverage2D coverage = reader.read(null);
CoordinateReferenceSystem crs = coverage.getCoordinateReferenceSystem2D();
Envelope env = coverage.getEnvelope();
RenderedImage image = coverage.getRenderedImage();
// exampleGridCoverageUsing end
}
示例7: SaveMapAsImage
import org.geotools.coverage.grid.io.AbstractGridFormat; //导入方法依赖的package包/类
public SaveMapAsImage(File file, File raster) throws IOException {
FileDataStore store = FileDataStoreFinder.getDataStore(file);
SimpleFeatureSource featureSource = store.getFeatureSource();
// Create a map content and add our shapefile to it
mapContent = new MapContent();
mapContent.setTitle("GeoTools Mapping");
AbstractGridFormat format = GridFormatFinder.findFormat(raster);
AbstractGridCoverage2DReader reader = format.getReader(raster);
GridCoverage2D cov;
try {
cov = reader.read(null);
} catch (IOException giveUp) {
throw new RuntimeException(giveUp);
}
Style rasterStyle = createRGBStyle(cov);
Layer rasterLayer = new GridReaderLayer(reader, rasterStyle);
mapContent.addLayer(rasterLayer);
Style style = SLD.createSimpleStyle(featureSource.getSchema());
Layer layer = new FeatureLayer(featureSource, style);
mapContent.addLayer(layer);
mapContent.getViewport().setCoordinateReferenceSystem(
DefaultGeographicCRS.WGS84);
frame = new JMapFrame(mapContent);
frame.enableStatusBar(true);
frame.enableToolBar(true);
JToolBar toolBar = frame.getToolBar();
toolBar.addSeparator();
SaveAction save = new SaveAction("Save");
toolBar.add(save);
frame.initComponents();
frame.setSize(1000, 500);
frame.setVisible(true);
}
示例8: createRasterLayer
import org.geotools.coverage.grid.io.AbstractGridFormat; //导入方法依赖的package包/类
private Layer createRasterLayer(File file, DataSet target_dataset)
throws IOException {
// declaration & initialization
Layer layer = null;
AbstractGridCoverage2DReader reader;
// Give a name to the population
String populationName = popNameFromFile(file.getPath());
// Find the file format
AbstractGridFormat format = GridFormatFinder.findFormat(file);
// Find out if we can read the file ...
// Unkown Format is not a typo from me, it is a typo from Geotools ...
if (format.getName() != "Unkown Format") {
reader = format.getReader(file);
} else {
System.err.println("Unknown file format for : " + file.getName());
return null;
}
// ... and do it
GridCoverage2D coverage = (GridCoverage2D) reader.read(null);
// create a population
Population<FT_Coverage> population = new Population<FT_Coverage>(
populationName);
org.opengis.geometry.Envelope envelope = coverage.getEnvelope();
// put the envelope of the image in the population
population.setEnvelope(
new GM_Envelope(envelope.getLowerCorner().getCoordinate()[0],
envelope.getUpperCorner().getCoordinate()[0],
envelope.getLowerCorner().getCoordinate()[1],
envelope.getUpperCorner().getCoordinate()[1]));
// add the data to the population
population.add(new FT_Coverage(coverage));
target_dataset.addPopulation(population);
// create a layer
layer = this.createLayer(populationName);
return layer;
}
示例9: addSource
import org.geotools.coverage.grid.io.AbstractGridFormat; //导入方法依赖的package包/类
protected void addSource( File imageMosaicSource ) throws IOException {
URL imageMosaicUrl = imageMosaicSource.toURI().toURL();
final AbstractGridFormat imageMosaicFormat = (AbstractGridFormat) GridFormatFinder.findFormat(imageMosaicUrl);
final ImageMosaicReader imReader = (ImageMosaicReader) imageMosaicFormat.getReader(imageMosaicUrl);
// ImageMosaicReader imReader = new ImageMosaicReader(imageMosaicSource);
if (readers.size() == 0) {
File propertiesFile = FileUtilities.substituteExtention(imageMosaicSource, "properties");
HashMap<String, String> propertiesMap = FileUtilities
.readFileToHashMap(propertiesFile.getAbsolutePath(), null, false);
String xyREs = propertiesMap.get("Levels");
String[] split = xyREs.split(",");
xRes = Double.parseDouble(split[0]);
yRes = Double.parseDouble(split[1]);
locationField = propertiesMap.get("LocationAttribute");
crs = imReader.getCoordinateReferenceSystem();
GeneralEnvelope originalEnvelope = imReader.getOriginalEnvelope();
llCorner = originalEnvelope.getLowerCorner().getCoordinate();
urCorner = originalEnvelope.getUpperCorner().getCoordinate();
SimpleFeatureCollection vectorBounds = OmsVectorReader.readVector(imageMosaicSource.getAbsolutePath());
boundsGeometries = FeatureUtilities.featureCollectionToGeometriesList(vectorBounds, true, locationField);
Envelope singleTileEnv = boundsGeometries.get(0).getEnvelopeInternal();
Envelope allTilesEnv = new Envelope();
for( Geometry boundsGeometry : boundsGeometries ) {
allTilesEnv.expandToInclude(boundsGeometry.getEnvelopeInternal());
}
if (allTilesEnv.getWidth() > singleTileEnv.getWidth()) {
isSingleInX = false;
}
if (allTilesEnv.getHeight() > singleTileEnv.getHeight()) {
isSingleInY = false;
}
}
readers.add(imReader);
}