@Override public GridCoverage2D getGridCoverage() { try { // There is a serious standardization failure around the axis order of WGS84. See issue #1930. // GeoTools assumes strict EPSG axis order of (latitude, longitude) unless told otherwise. // Both NED and SRTM data use the longitude-first axis order, so OTP makes grid coverages // for unprojected DEMs assuming coordinates are in (longitude, latitude) order. Hints forceLongLat = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); GeoTiffFormat format = new GeoTiffFormat(); GeoTiffReader reader = format.getReader(path, forceLongLat); coverage = reader.read(null); LOG.info("Elevation model CRS is: {}", coverage.getCoordinateReferenceSystem2D()); } catch (IOException e) { throw new RuntimeException("Error getting coverage automatically. ", e); } return coverage; }
public RasterAsPointFeatureCollection(final GridCoverage2D gc2d) throws IOException { this(gc2d, false, gc2d.getCoordinateReferenceSystem2D()); }
final CoordinateReferenceSystem coverageCRS = gridCoverage.getCoordinateReferenceSystem2D(); if (!CRS.equalsIgnoreMetadata(coverageCRS, destinationCRS)) { final MathTransform transform =
new ReferencedEnvelope( CRS.transform(mt2D, rasterBounds_, null), gc2d.getCoordinateReferenceSystem2D()); } catch (Exception e) { final IOException ioe = new IOException(); final CoordinateReferenceSystem coverageCRS = gc2d.getCoordinateReferenceSystem2D();
private static GridCoverage2D existingCoverage( GridCoverage2D coverage, CoordinateReferenceSystem targetCRS, GridGeometry2D targetGG) { // NoData and ROI must be handled ROI roiProp = CoverageUtilities.getROIProperty(coverage); Object nodataProp = CoverageUtilities.getNoDataProperty(coverage); boolean hasROI = (roiProp != null); boolean hasNoData = (nodataProp != null); if (hasROI || hasNoData) { return null; } while (!equivalent(coverage.getGridGeometry(), targetGG) || (!CRS.equalsIgnoreMetadata(targetCRS, coverage.getCoordinateReferenceSystem()) && !CRS.equalsIgnoreMetadata( targetCRS, coverage.getCoordinateReferenceSystem2D()))) { if (!(coverage instanceof Resampler2D)) { return null; } final List<GridCoverage> sources = coverage.getSources(); assert sources.size() == 1 : sources; coverage = (GridCoverage2D) sources.get(0); } return coverage; }
final GeneralEnvelope coverageEnvelope = (GeneralEnvelope) inputCoverage.getEnvelope(); final CoordinateReferenceSystem coverageCRS = inputCoverage.getCoordinateReferenceSystem2D();
final CoordinateReferenceSystem crs = coverage.getCoordinateReferenceSystem2D(); if (!CRS.equalsIgnoreMetadata(crs, source.getCoordinateReferenceSystem2D()) || !CRS.equalsIgnoreMetadata( gridToCRS, source.getGridGeometry().getGridToCRS2D())) {
CoordinateReferenceSystem sourceCRS = src.getCoordinateReferenceSystem2D(); CoordinateReferenceSystem targetCRS = dst.getCoordinateReferenceSystem2D();
final CoordinateReferenceSystem crs = coverage.getCoordinateReferenceSystem2D();
/** * Returns a two-dimensional CRS for the given coverage. This method performs a <cite>best * effort</cite>; the returned CRS is not garanteed to be the most appropriate one. * * @param coverage The coverage for which to obtains a two-dimensional CRS. * @return The two-dimensional CRS. * @throws TransformException if the CRS can't be reduced to two dimensions. */ public static CoordinateReferenceSystem getCRS2D(final Coverage coverage) throws TransformException { if (coverage instanceof GridCoverage2D) { return ((GridCoverage2D) coverage).getCoordinateReferenceSystem2D(); } if (coverage instanceof GridCoverage) { final GridGeometry2D geometry = GridGeometry2D.wrap(((GridCoverage) coverage).getGridGeometry()); if (geometry.isDefined(GridGeometry2D.CRS_BITMASK)) { return geometry.getCoordinateReferenceSystem2D(); } else try { return geometry.reduce(coverage.getCoordinateReferenceSystem()); } catch (FactoryException exception) { // Ignore; we will fallback on the code below. } } return CRSUtilities.getCRS2D(coverage.getCoordinateReferenceSystem()); }
final CoordinateReferenceSystem crs = source.getCoordinateReferenceSystem2D(); final Envelope2D envelope = source.getEnvelope2D(); if (new ReferencedEnvelope( roiInput.getEnvelopeInternal(), source.getCoordinateReferenceSystem2D()) .intersects((Envelope) new ReferencedEnvelope(envelope))) { final java.awt.Polygon shapePolygon =
final CoordinateReferenceSystem crs = gc.getCoordinateReferenceSystem2D();
CoordinateReferenceSystem returnedCRS = null; if (coverage instanceof GridCoverage2D) { returnedCRS = ((GridCoverage2D) coverage).getCoordinateReferenceSystem2D();
yRes = regionMap.get(CoverageUtilities.YRES); gridGeometry = inGeodata.getGridGeometry(); crs = inGeodata.getCoordinateReferenceSystem2D(); } else { imageProperties.init(inputRI);
/** * Wraps a grid coverage into a Feature. Code lifted from ArcGridDataSource (temporary). * * @param coverage the grid coverage. * @return a feature with the grid coverage envelope as the geometry and the grid coverage * itself in the "grid" attribute. */ @SuppressWarnings("unchecked") public static SimpleFeatureCollection wrapGridCoverage(final GridCoverage2D coverage) throws TransformException, SchemaException { final Polygon bounds = getPolygon(coverage.getEnvelope2D()); final CoordinateReferenceSystem sourceCRS = coverage.getCoordinateReferenceSystem2D(); SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder(getTypeFactory()); ftb.setName("GridCoverage"); ftb.add("geom", Polygon.class, sourceCRS); ftb.add("grid", GridCoverage.class); SimpleFeatureType schema = ftb.buildFeatureType(); // create the feature SimpleFeatureBuilder fb = new SimpleFeatureBuilder(schema, getFeatureFactory()); fb.add(bounds); fb.add(coverage); SimpleFeature feature = fb.buildFeature(null); final DefaultFeatureCollection collection = new DefaultFeatureCollection(); collection.add(feature); return collection; }
ftBuilder.setCRS(gc2d.getCoordinateReferenceSystem2D());
(ParameterValueGroup) processor.getOperation("Resample").getParameters().clone(); param.parameter("source").setValue(gc); param.parameter("CoordinateReferenceSystem").setValue(gc.getCoordinateReferenceSystem2D()); param.parameter("GridGeometry").setValue(newGridGeometry); param.parameter("InterpolationType")
((GridCoverage2D) coverage).getCoordinateReferenceSystem2D();
visual.getName(), newImage, visual.getCoordinateReferenceSystem2D(), visual.getGridGeometry().getGridToCRS(), bands,
public Object evaluate(Object gc) { GridCoverage2D coverage = (GridCoverage2D) gc; Envelope env = coverage.getEnvelope(); GeometryFactory gf = new GeometryFactory(); Point center = gf.createPoint(new Coordinate(env.getMedian(0), env.getMedian(1))); SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.setName("center"); tb.add("geom", Point.class, coverage.getCoordinateReferenceSystem2D()); SimpleFeatureType ft = tb.buildFeatureType(); SimpleFeatureBuilder fb = new SimpleFeatureBuilder(ft); fb.add(center); SimpleFeature f = fb.buildFeature(null); return DataUtilities.collection(f); } }