From: Martin D. <mar...@no...> - 2005-03-08 11:32:43
|
toddfx a =E9crit : > So I'm wondering if anyone has a small code snippet that shows how to > load georeferenced image files (jpg with worldfile or geotiff). An > example of creating a layer and drawing a polygon on it would be great > too. For loading a georeferenced image ("GridCoverage" in OpenGIS terms), you=20 catch us in a transition phase. You can use some classes right now, but=20 before it is worth to know the following: - org.geotools.gc contains a legacy implementation of GridCoverage. This implementation was built on top of old standards (the standards changed; not our fault!). - org.geotools.coverage.grid contains a partial port of GridCoverage to new standards. It is partial only because it take in account the ISO 19111 standard only (Coordinate Reference System). The ISO 19123 standard (Grid Coverage itself) will be taken in account later, in a second phase. So you catch us right in a transition phase. How to built a GridCoverage. Step to follows: 1) Load yours image using the standard ImageIO API bundle in J2SE 1.4. 2) The hard part: Gets the envelope (the "real world" coordinate of the bounding box of yours image) and the CRS (Coordinate Reference System) of yours image. If those informations are bundle in a .prj file, I don't know how hard it is to read it. Someone (Simone) is just about to commit some code for reading .prj files, but it is not done yet. In a first approach (for testing purpose), it may be easier to hard code yours Envelope and CRS. 3) Construct a org.geotools.coverage.grid.GridCoverage2D object with the image, the envelope and the CRS in arguments. A part that is a little bit difficult to explain is the SampleDimension argument. Basically, a SampleDimension is a band. Except that SampleDimension is not that much about the color; it is more about the *meaning* of pixel values. For example for a Digital Elevation Model, it may be the height in meters. 4) Do some tests with GridCoverage2D.evaluate methods in order to see if you gets the expected values. Next step will be to display the image. More on this topic tomorrow (the=20 J2D-renderer has not yet been ported to new CRS and GridCoverage API,=20 and the port will be quite long. But I will try to commit some bridges=20 as temporary patchs tomorrow). Martin. |