I want to automatically georeference an image using the method;-
1 ProductProjectionBuilder.createProductProjection(sourceProduct, mapInfo, name, desc)
As you can see MapInfo is one of the arguments. The MapInfo class holds information required to bring the cartographic map co-ordinate system to a raster co-ordinate system and back. MapInfo constructor is as follows;
1 MapInfo(MapProjection mapProjection, float pixelX, float pixelY, float easting, float northing, float pixelSizeX, float pixelSizeY, Datum datum)
How do i read these parameters from a raw image.
MapProjection mapProjection,
float pixelX,
float pixelY,
float easting,
float northing,
float pixelSizeX,
float pixelSizeY,
Here is my indented class
1
2import java.awt.Rectangle;
3import java.io.IOException;
4import org.esa.beam.framework.dataio.ProductIO;
5import org.esa.beam.framework.dataio.ProductProjectionBuilder;
6import org.esa.beam.framework.datamodel.Product;
7
8import org.esa.beam.framework.dataop.maptransf.MapInfo;
9import org.esa.beam.framework.dataop.maptransf.MapProjection;
10
11public class AutoProjectImage {
12
13 public static void main(String[] args) {
14
15 String filePath = args[0]; // Raw Image in.
16
17 String targetFilename = args[1];// Georeferenced Image out
18
19 try {
20 System.out.println("Loading rawProduct: " + filePath);
21
22 Product rawProduct = ProductIO.readProduct(filePath, null);
23
24 MapProjection mapProjection = Geographic Lat/Lon
25
26 MapInfo theMapInfo = MapInfo(MapProjection mapProjection, float pixelX, float pixelY, float easting, float northing, float pixelSizeX, float pixelSizeY, Datum datum)-
27 //"This is where my problem is. How do why construct MapInfo for a raw Image that has not been projected?"
28
29 Product projectedProduct = ProductProjectionBuilder.createProductProjection(rawProduct, theMapInfo, "projectedProduct", "Automatically gereferenced product");
30
31 ProductIO.writeProduct(projectedProduct, targetFilename, null);
32
33 rawProduct.closeProductReader();
34
35 projectedProduct.closeProductWriter();
36
37 System.out.println("Process Complete:");
38
39 } catch (IOException e) {
40
41 System.out.println("I/O error: " + e.getMessage());
42
43 e.printStackTrace();
44 }
45
46
47 }