Hello Jon Jon Blower a écrit : > I'm looking for a way of rendering an image of some satellite data. > Each "ground pixel" in the data is represented as a quadrilateral in > lat-lon coordinates, and each pixel is associated with a numerical > value (ozone concentration in this case). (I guess this is a > DiscretePolygonCoverage in ISO19123 terminology.) Does anyone have > any hints for how I could use GeoTools to do this? I've looked > through the User Guide and javadocs for the latest GeoTools but am > getting a bit lost in FeatureCollections and the Feature model.
According ISO 19123, a Coverage is a Feature. However in GeoTools implementation this relationship is not yet implemented; Coverages are still living alone, so we can ommit Feature for now. GridCoverage2D were designed for the kind of work you are reporting (I'm an oceanographer working with Sea Surface Temperature, Chlorophyl-a concentrations, etc.). The steps depends slightly on whatever your data are Ozone concentration as floating point values (case A) or integer values to be converted to Ozone concentration through a linear relationship (ozone = value*scale + offset; I will call that "case B"). STEP 1 ------ If you are in case A: Get your data as a matrix of floating point values. Values must be straight ozone concentration. IMPORTANT: missing values (if any) must be Float.NaN, NOT some magic value like -9999. Example (see the construction of the Raster, you can ommit the remainding for now): http://svn.geotools.org/trunk/demo/coverage-use/src/main/java/org/geotools/demo/coverage/FloatRasterDemo.java If you are in case B: Get your integer data as a RenderedImage. Step 2: ------- Choose some "scale" and "offset" factor for converting integer data to ozone concentration. Note: for the remaining of this discussion, I will call the integer data "packed values" and the ozone concentration "geophysics values". If you are in case B: "scale" and "offset" are directly the values that you use for converting your packed values to geophysics values. You will need also to specify the "nodata" value, if any. If you are in case B: Choose a "scale", "offset" and "nodata" value as if you were converting some (non-existant for now) packed values to ozone values. I suggest that you choose "0" for "nodata", and that you adjust "scale" and "offset" in such a way that "scale + offset" give approximatively the minimal expected geophysics values, and "255*scale + offset" gives approximatively the maximal expected geophysics values. It is not a big deal if some geophysics values exists outside that range. Step 3: ------- Creates Category from the above values (note: I arbitrarily use Color.GRAY for "nodata", but choose any color you wish. I also assume that you have applied my suggestion of using 0 for "nodata", but you can change the number below if you selected an other values. Just make sure that the ranges don't overlaps): Category nodataCategory = new Category("No data", Color.GRAY, 0); Category ozoneCategory = new Category("Ozone", colors, 1, 255, scale, offset); http://javadoc.geotools.fr/snapshot/org/geotools/coverage/Category.html#Category(java.lang.CharSequence,%20java.awt.Color[],%20org.geotools.util.NumberRange,%20double,%20double) Note: "palette" is an array having the colors you wish apply. The first element in this array is the color to apply to the minimal ozone concentration, and the last element is the color to apply to the maximum ozone concentration. The array length doesn't have to be 255. GeoTools will interpolate colors as needed. Step 4: ------ Create a GridSampleDimension with the above categories using this constructor: http://javadoc.geotools.fr/snapshot/org/geotools/coverage/GridSampleDimension.html#GridSampleDimension(java.lang.CharSequence,%20org.geotools.coverage.Category[],%20javax.measure.unit.Unit) If you are in case A: Once your GridSampleDimension is created (lets call it sd), invoke: sd = sd.geophysics(true). If you are in case B, *don't* do the above step (or do it with a "false" value in argument). Step 5: ------- Create a GridCoverage2D using the above SampleDimension and your raster: http://javadoc.geotools.fr/snapshot/org/geotools/coverage/grid/GridCoverageFactory.html#create(java.lang.CharSequence,%20java.awt.image.WritableRaster,%20org.opengis.geometry.Envelope,%20org.geotools.coverage.GridSampleDimension[]) You have other constructors - pickup the one most convenient for you. Step 6: ------- Use your coverage. You have different views according what you want to do: * If you want to do analyses, use: coverage = coverage.view(ViewType.GEOPHYSICS); double[] data = null; data = coverage.evaluate(coordinate, data); TIP: the above does not interpolate. If you want interpolations, do: coverage = Operations.interpolate(coverage, "bilinear"); * If you want to display, use: coverage = coverage.view(ViewType.RENDERED); Note that in this case, the "evaluate" method returns packed values, not geophysics values. Martin ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
