当前位置: 首页>>代码示例>>Java>>正文


Java GridCoverageFactory.create方法代码示例

本文整理汇总了Java中org.geotools.coverage.grid.GridCoverageFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Java GridCoverageFactory.create方法的具体用法?Java GridCoverageFactory.create怎么用?Java GridCoverageFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.geotools.coverage.grid.GridCoverageFactory的用法示例。


在下文中一共展示了GridCoverageFactory.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.geotools.coverage.grid.GridCoverageFactory; //导入方法依赖的package包/类
@DescribeResult(name = "result", description = "This is just a pass-through, the key is to provide enough information within invertQuery to perform a map to screen transform")
public GridCoverage2D execute(
		@DescribeParameter(name = "data", description = "Feature collection containing the rendered image")
		final SimpleFeatureCollection features )
		throws ProcessException {
	// vector-to-raster render transform that take a single feature that
	// wraps a distributed render result and converts it to a GridCoverage2D
	if (features != null) {
		final SimpleFeatureIterator it = features.features();
		if (it.hasNext()) {
			final SimpleFeature resultFeature = features.features().next();
			final DistributedRenderResult actualResult = (DistributedRenderResult) resultFeature.getAttribute(0);
			final DistributedRenderOptions renderOptions = (DistributedRenderOptions) resultFeature.getAttribute(1);
			// convert to the GridCoverage2D required for output
			final GridCoverageFactory gcf = CoverageFactoryFinder
					.getGridCoverageFactory(GeoTools.getDefaultHints());
			final BufferedImage result = actualResult.renderComposite(renderOptions);
			final GridCoverage2D gridCov = gcf.create(
					"Process Results",
					result,
					renderOptions.getEnvelope());
			return gridCov;
		}
	}
	return null;
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:27,代码来源:InternalDistributedRenderProcess.java

示例2: testExactUpScale

import org.geotools.coverage.grid.GridCoverageFactory; //导入方法依赖的package包/类
@Test
public void testExactUpScale() {
    float[][] grid = new float[][] {{1,2},{3,4}};
    final GridCoverageFactory coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints());
    final GridCoverage2D coverage = coverageFactory.create("geohashGridAgg", grid, new ReferencedEnvelope(0,1,0,1,null));
    GridCoverage2D scaled = GridCoverageUtil.scale(coverage, 4, 4);
    final RenderedImage renderedImage = scaled.getRenderedImage();
    assertEquals(4, renderedImage.getWidth());
    assertEquals(4, renderedImage.getHeight());
    float[][] expected = new float[][] {{1,1,2,2},{1,1,2,2},{3,3,4,4},{3,3,4,4}};
    IntStream.range(0,4).forEach(i->IntStream.range(0, 4).forEach(j -> {
        float actual = scaled.evaluate(new GridCoordinates2D(j,i), new float[1])[0];
        assertEquals(expected[i][j], actual, 1e-10);
    }));
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:16,代码来源:GridCoverageUtilTest.java

示例3: testExactDownScale

import org.geotools.coverage.grid.GridCoverageFactory; //导入方法依赖的package包/类
@Test
public void testExactDownScale() {
    float[][] grid = new float[][] {{1,1,2,2},{1,1,2,2},{3,3,4,4},{3,3,4,4}};
    final GridCoverageFactory coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints());
    final GridCoverage2D coverage = coverageFactory.create("geohashGridAgg", grid, new ReferencedEnvelope(0,1,0,1,null));
    GridCoverage2D scaled = GridCoverageUtil.scale(coverage, 2,2);
    final RenderedImage renderedImage = scaled.getRenderedImage();
    assertEquals(2, renderedImage.getWidth());
    assertEquals(2, renderedImage.getHeight());
    float[][] expected = new float[][] {{1,2},{3,4}};
    IntStream.range(0,2).forEach(i->IntStream.range(0, 2).forEach(j -> {
        float actual = scaled.evaluate(new GridCoordinates2D(j,i), new float[1])[0];
        assertEquals(expected[i][j], actual, 1e-10);
    }));
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:16,代码来源:GridCoverageUtilTest.java

示例4: testInexactScale

import org.geotools.coverage.grid.GridCoverageFactory; //导入方法依赖的package包/类
@Test
public void testInexactScale() {
    float[][] grid = new float[][] {{1,2},{3,4}};
    final GridCoverageFactory coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints());
    final GridCoverage2D coverage = coverageFactory.create("geohashGridAgg", grid, new ReferencedEnvelope(0,1,0,1,null));
    GridCoverage2D scaled = GridCoverageUtil.scale(coverage, 3, 7);
    final RenderedImage renderedImage = scaled.getRenderedImage();
    assertEquals(7, renderedImage.getWidth());
    assertEquals(3, renderedImage.getHeight());
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:11,代码来源:GridCoverageUtilTest.java

示例5: testSmallScale

import org.geotools.coverage.grid.GridCoverageFactory; //导入方法依赖的package包/类
@Test
public void testSmallScale() {
    float[][] grid = new float[1500][1500];
    final GridCoverageFactory coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints());
    final GridCoverage2D coverage = coverageFactory.create("geohashGridAgg", grid, new ReferencedEnvelope(0,1,0,1,null));
    GridCoverage2D scaled = GridCoverageUtil.scale(coverage, 1501, 1499);
    final RenderedImage renderedImage = scaled.getRenderedImage();
    assertEquals(1499, renderedImage.getWidth());
    assertEquals(1501, renderedImage.getHeight());
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:11,代码来源:GridCoverageUtilTest.java

示例6: testLargeScale

import org.geotools.coverage.grid.GridCoverageFactory; //导入方法依赖的package包/类
@Test
public void testLargeScale() {
    float[][] grid = new float[2][2];
    final GridCoverageFactory coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints());
    final GridCoverage2D coverage = coverageFactory.create("geohashGridAgg", grid, new ReferencedEnvelope(0,1,0,1,null));
    GridCoverage2D scaled = GridCoverageUtil.scale(coverage, 1501, 1499);
    final RenderedImage renderedImage = scaled.getRenderedImage();
    assertEquals(1499, renderedImage.getWidth());
    assertEquals(1501, renderedImage.getHeight());
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:11,代码来源:GridCoverageUtilTest.java

示例7: testCrop

import org.geotools.coverage.grid.GridCoverageFactory; //导入方法依赖的package包/类
@Test
public void testCrop() throws MismatchedDimensionException, NoSuchAuthorityCodeException, FactoryException {
    float[][] grid = new float[][] {{3,4},{1,2}};
    final GridCoverageFactory coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints());
    final GridCoverage2D coverage = coverageFactory.create("geohashGridAgg", grid, new ReferencedEnvelope(0,20,0,20,null));
    final ReferencedEnvelope envelope = new ReferencedEnvelope(10,20,10,20,null);
    final GridCoverage2D croppedCoverage = GridCoverageUtil.crop(coverage, envelope);
    final RenderedImage renderedImage = croppedCoverage.getRenderedImage();
    assertEquals(1, renderedImage.getWidth());
    assertEquals(1, renderedImage.getHeight());
    assertEquals(4, croppedCoverage.evaluate(new Point2D.Double(15,15), new float[1])[0], 1e-10);
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:13,代码来源:GridCoverageUtilTest.java

示例8: createCoverage

import org.geotools.coverage.grid.GridCoverageFactory; //导入方法依赖的package包/类
/**
 * Creates the
 *
 * @param data
 * @return
 */
public GridCoverage2D createCoverage(float[] data, int columns, int rows) {
  GridCoverageFactory gcf = CoverageFactoryFinder.getGridCoverageFactory(null);
  TiledImage img = ceateImageContent(data, columns, rows);
  ReferencedEnvelope env = createEnvelope();
  return gcf.create("coverage", img, env);
}
 
开发者ID:MeteoGroup,项目名称:grib2geotiff,代码行数:13,代码来源:GeoTiffExporter.java

示例9: createCoverageFromTemplate

import org.geotools.coverage.grid.GridCoverageFactory; //导入方法依赖的package包/类
/**
 * Creates a new {@link GridCoverage2D} using an existing as template.
 * 
 * @param template the template to use.
 * @param value the value to set the new raster to, if not <code>null</code>.
 * @param writableRasterHolder an array of length 1 to place the writable raster in, that 
 *                  was can be used to populate the coverage. If <code>null</code>, it is ignored.
 * @return the new coverage.
 */
public static GridCoverage2D createCoverageFromTemplate( GridCoverage2D template, Double value,
        WritableRaster[] writableRasterHolder ) {
    RegionMap regionMap = getRegionParamsFromGridCoverage(template);

    double west = regionMap.getWest();
    double south = regionMap.getSouth();
    double east = regionMap.getEast();
    double north = regionMap.getNorth();
    int cols = regionMap.getCols();
    int rows = regionMap.getRows();
    ComponentSampleModel sampleModel = new ComponentSampleModel(DataBuffer.TYPE_DOUBLE, cols, rows, 1, cols, new int[]{0});

    WritableRaster raster = RasterFactory.createWritableRaster(sampleModel, null);
    if (value != null) {
        // autobox only once
        double v = value;
        for( int y = 0; y < rows; y++ ) {
            for( int x = 0; x < cols; x++ ) {
                raster.setSample(x, y, 0, v);
            }
        }
    }
    if (writableRasterHolder != null) {
        writableRasterHolder[0] = raster;
    }

    Envelope2D writeEnvelope = new Envelope2D(template.getCoordinateReferenceSystem(), west, south, east - west,
            north - south);
    GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null);
    GridCoverage2D coverage2D = factory.create("newraster", raster, writeEnvelope);
    return coverage2D;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:42,代码来源:CoverageUtilities.java

示例10: createSubCoverageFromTemplate

import org.geotools.coverage.grid.GridCoverageFactory; //导入方法依赖的package包/类
/**
 * Create a subcoverage given a template coverage and an envelope.
 * 
 * @param template the template coverage used for the resolution.
 * @param subregion the envelope to extract to the new coverage. This should
 *                  be snapped on the resolution of the coverage, in order to avoid 
 *                  shifts.
 * @param value the value to set the new raster to, if not <code>null</code>. 
 * @param writableRasterHolder an array of length 1 to place the writable raster in, that 
 *                  was can be used to populate the coverage. If <code>null</code>, it is ignored.
 * @return the new coverage.
 */
public static GridCoverage2D createSubCoverageFromTemplate( GridCoverage2D template, Envelope2D subregion, Double value,
        WritableRaster[] writableRasterHolder ) {
    RegionMap regionMap = getRegionParamsFromGridCoverage(template);
    double xRes = regionMap.getXres();
    double yRes = regionMap.getYres();

    double west = subregion.getMinX();
    double south = subregion.getMinY();
    double east = subregion.getMaxX();
    double north = subregion.getMaxY();

    int cols = (int) ((east - west) / xRes);
    int rows = (int) ((north - south) / yRes);
    ComponentSampleModel sampleModel = new ComponentSampleModel(DataBuffer.TYPE_DOUBLE, cols, rows, 1, cols, new int[]{0});

    WritableRaster writableRaster = RasterFactory.createWritableRaster(sampleModel, null);
    if (value != null) {
        // autobox only once
        double v = value;
        for( int y = 0; y < rows; y++ ) {
            for( int x = 0; x < cols; x++ ) {
                writableRaster.setSample(x, y, 0, v);
            }
        }
    }
    if (writableRasterHolder != null)
        writableRasterHolder[0] = writableRaster;
    Envelope2D writeEnvelope = new Envelope2D(template.getCoordinateReferenceSystem(), west, south, east - west,
            north - south);
    GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null);
    GridCoverage2D coverage2D = factory.create("newraster", writableRaster, writeEnvelope);
    return coverage2D;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:46,代码来源:CoverageUtilities.java

示例11: buildCoverage

import org.geotools.coverage.grid.GridCoverageFactory; //导入方法依赖的package包/类
/**
 * Creates a {@link GridCoverage2D coverage} from the {@link RenderedImage image} and the necessary geographic Information.
 * 
 * @param name the name of the coverage.
 * @param renderedImage the image containing the data.
 * @param envelopeParams the map of boundary parameters.
 * @param crs the {@link CoordinateReferenceSystem}.
 * @return the {@link GridCoverage2D coverage}.
 */
public static GridCoverage2D buildCoverage( String name, RenderedImage renderedImage, HashMap<String, Double> envelopeParams,
        CoordinateReferenceSystem crs ) {

    double west = envelopeParams.get(WEST);
    double south = envelopeParams.get(SOUTH);
    double east = envelopeParams.get(EAST);
    double north = envelopeParams.get(NORTH);
    Envelope2D writeEnvelope = new Envelope2D(crs, west, south, east - west, north - south);
    GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null);

    GridCoverage2D coverage2D = factory.create(name, renderedImage, writeEnvelope);
    return coverage2D;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:23,代码来源:CoverageUtilities.java

示例12: saveRaster

import org.geotools.coverage.grid.GridCoverageFactory; //导入方法依赖的package包/类
/**
 * Save a set of raster data at a given location.
 * @param location The file location at which to save the raster.
 * @param raster The raw pixel values for the raster.
 * @param extents The extent of the raster.
 * @param properties The meta-data for the raster.
 * @throws IOException thrown if unable to save the raster.
 */
public static void saveRaster(File location, WritableRaster raster,
                              Envelope2D extents, GridSampleDimension[] properties) throws IOException {
    GridCoverage2D targetRaster = null;
    try {
        GridCoverageFactory factory = new GridCoverageFactory();
        targetRaster = factory.create(location.getName(), raster, extents, properties);
        saveRaster(location, targetRaster);
    } finally {
        disposeRaster(targetRaster);
    }
}
 
开发者ID:SEEG-Oxford,项目名称:ABRAID-MP,代码行数:20,代码来源:RasterUtils.java

示例13: exampleGridCoverageFactory

import org.geotools.coverage.grid.GridCoverageFactory; //导入方法依赖的package包/类
@SuppressWarnings("unused")
void exampleGridCoverageFactory() throws Exception {
    
    ReferencedEnvelope referencedEnvelope = null;
    BufferedImage bufferedImage = null;
    // exampleGridCoverageFactory start
    GridCoverageFactory factory = new GridCoverageFactory();
    GridCoverage2D coverage = factory.create("GridCoverage", bufferedImage, referencedEnvelope);
    // exampleGridCoverageFactory end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:11,代码来源:CoverageExamples.java

示例14: bind

import org.geotools.coverage.grid.GridCoverageFactory; //导入方法依赖的package包/类
/**
 * Binding function
 * 
 * @param image buffered image that needs to be binded
 * @param filename absolute path of result tiff file with binded image
 * @param left left border of bound rectangle
 * @param top top border of bound rectangle
 * @param right right border of bound rectangle
 * @param bottom bottom border of bound rectangle 
 * @param crsWKT well-known text that describes coordinate reference system
 *         
 */
public final static void bind(BufferedImage image,String filename, double left, double top, double right, double bottom, String crsWKT, boolean usingJpegCompression, float jpegQuality) throws IOException, FactoryException{
	final File f = new File(filename);
	final ImageOutputStream imageOutStream = ImageIO.createImageOutputStream(f);
	final GeoTiffWriter writer = new GeoTiffWriter(imageOutStream);
	
	final GeoTiffFormat format = new GeoTiffFormat();
	final GeoTiffWriteParams wp = new GeoTiffWriteParams();
	wp.setCompressionMode(GeoTiffWriteParams.MODE_EXPLICIT);
	if (usingJpegCompression){
		wp.setCompressionType("JPEG");
		wp.setCompressionQuality(jpegQuality/100F);
	}
	wp.setTilingMode(GeoToolsWriteParams.MODE_EXPLICIT);
	wp.setTiling(256, 256);
	 
	final ParameterValueGroup writerParams = format.getWriteParameters();
	writerParams.parameter(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName().toString())
	            .setValue(wp);
	
	CoordinateReferenceSystem crs = CRS.parseWKT(crsWKT);
	ReferencedEnvelope envelope = new ReferencedEnvelope(left, right, top, bottom, crs);
	GridCoverageFactory factory = new GridCoverageFactory();
	GridCoverage2D gc = factory.create("IMG", image, envelope);
	writer.write(gc, (GeneralParameterValue[]) writerParams.values().toArray(new GeneralParameterValue[1]));
	imageOutStream.flush();
	imageOutStream.close();
   }
 
开发者ID:SVoyt,项目名称:pyramaker,代码行数:40,代码来源:ImageBinder.java

示例15: bufferedImageToGridCoverage2D

import org.geotools.coverage.grid.GridCoverageFactory; //导入方法依赖的package包/类
public static GridCoverage2D bufferedImageToGridCoverage2D(
    BufferedImage image, Envelope env) {
  GridCoverageFactory coverageFactory = new GridCoverageFactory();
  GridCoverage2D newCoverage = coverageFactory.create("coverage", image, env);
  return newCoverage;
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:7,代码来源:ImageUtil.java


注:本文中的org.geotools.coverage.grid.GridCoverageFactory.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。