Hi Matthias, sorry for the late reply. I think this is related to PixelIsCorner vs PixelIsCenter convention. http://docs.geotools.org/stable/javadocs/org/geotools/geometry/GeneralEnvelope.html In OGC, the grid to CRS transform maps the cell center. I think that when using the evaluate method you should provide the cell's center coordinates while GeneralEnvelope reports the cell's corner coordinates. (So there is an half pixel shift to be taken into account)
Something like this should work: GridGeometry gridGeometry = gridCoverage.getGridGeometry(); MathTransform transform = gridGeometry.getGridToCRS(); // supposing you want to get a coverage's corner DirectPosition2D sourceDp = new DirectPosition2D(gridGeometry.getGridRange().getLow(0), gridGeometry.getGridRange().getHigh(1)); DirectPosition2D targetDp = new DirectPosition2D(); transform.transform(sourceDp, targetDp); gridCoverage.evaluate(targetDp); Hope this helps. Daniele On Fri, Feb 8, 2019 at 2:19 PM Matthias Müller < matthias_muel...@tu-dresden.de> wrote: > I am trying to lookup 2D point values from a GeoTiff coverage an got the > following error from /GridCoverage2D.evaluate()/ [1] (Geotools 20.2) > > From the GeoTiff's envelope I would assume that the point (0, -90) is > within the valid extent but /GridCoverage2D.evaluate()/ seems to think > otherwise. It the output of /GridCoverage2D.getEnvelope()/ consistent with > the (minimal) bounding box of the coverage or must I use a different query > to obtain the valid extent? > > Thanks, > Matthias > > p.s.: I tested this with a few thousand other points, distributed > world-wide. So the general procedure seems to work. > > [1]: > GEOGCS["WGS 84", > DATUM["World Geodetic System 1984", > SPHEROID["WGS 84", 6378137.0, 298.257223563, > AUTHORITY["EPSG","7030"]], > AUTHORITY["EPSG","6326"]], > PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], > UNIT["degree", 0.017453292519943295], > AXIS["Geodetic longitude", EAST], > AXIS["Geodetic latitude", NORTH], > AUTHORITY["EPSG","4326"]] > GeneralEnvelope[(-180.0, -90.00000000000001), (180.00000000000006, 90.0)] > > ... > > org.opengis.coverage.PointOutsideCoverageException: Coordinate (0, -90) is > outside coverage. > > at > org.geotools.coverage.grid.GridCoverage2D.evaluate(GridCoverage2D.java:454) > at > org.geotools.coverage.grid.GridCoverage2D.evaluate(GridCoverage2D.java:398) > _______________________________________________ > GeoTools-GT2-Users mailing list > GeoTools-GT2-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > -- Regards, Daniele Romagnoli == GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information. == Ing. Daniele Romagnoli Senior Software Engineer GeoSolutions S.A.S. Via di Montramito 3/A 55054 Massarosa (LU) Italy phone: +39 0584 962313 fax: +39 0584 1660272 http://www.geo-solutions.it http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.
_______________________________________________ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users