Welcome to the BEAM Forum!

We encourage you to sign in our forum and participate in the BEAM community. The forum is maintained by the BEAM project team who will most likely answer your questions within 24 hours (except during common holidays) - if not done by other community members. Collaborate, share your knowledge and learn from other users!

If you don't find what you are looking for, please also consider the following external forums:

Combination View Flat View Tree View
Threads [ Previous | Next ]
RE: Programatically georeference/Project an Images
toggle
Hi everyone, I am in charge of data in my organization and have to georeference and process ENVISAT data. These data come in bulk and overwhelms me.

I am trying to come with a class in Java using Beam programming in eclipse that will be invoked by a batch file, suplied by the input image path and output image path as arguments then it automatically georefernces the image, and writes the georeferenced image to a folder.

Here is java class of how i am thinking about it.

Imports <here>

public class ProjectImage {

<feilds here>

public static void main(String[] args) {

String inFilePath = args[0];

String targetFilename = args[1];

try {
_inFile = inFilePath;

Resampling reSamp = org.esa.beam.framework.dataop.resamp.Resampling.NEAREST_NEIGHBOUR;


System.out.println(_paramResampling);

initParameters();

_outputMapInfo.setResampling(reSamp);

final String prodName = _paramNewProductName.getValueAsText();

final String prodDesc = _paramNewProductDesc.getValueAsText();



final boolean includeGrids = Boolean.parseBoolean(_paramIncludeTiePointGrids.getValueAsText());



Product product2 = ProductProjectionBuilder.createProductProjection(getSourceProduct(),
false, includeGrids,
_outputMapInfo,
prodName, prodDesc);

ProductIO.writeProduct(product2, targetFilename, null);


} catch (IOException e) {

System.out.println("I/O error: " + e.getMessage());

e.printStackTrace();}
}

public static Product getSourceProduct() {

try {

_sourceProduct = ProductIO.readProduct(_inFile , null);



} catch (IOException e) {

System.out.println("I/O error: " + e.getMessage());
e.printStackTrace();
}



return _sourceProduct;
}


Any one who can assist please.

What are the most necessary classes for projection?

How do you get the MapInfo of a raw image(that has not been georeferenced)?

What is the best format to write to the resulting image without removing any band, *.N1 or *.dim any other??
Flag Flag
RE: Programatically georeference/Project an Images
2/11/10 11:13 AM as a reply to Kabuchanga Eric.
trying to reformat your code to make it easier to help - this is not yet an answer to your question...

 1
 2Imports <here>         
 3
 4public class ProjectImage {
 5
 6<fields here>
 7
 8public static void main(String[] args) {
 9       
10        String inFilePath = args[0]; 
11        String targetFilename = args[1];
12        try { 
13            _inFile = inFilePath;
14            Resampling reSamp = org.esa.beam.framework.dataop.resamp
15                                               .Resampling.NEAREST_NEIGHBOUR;         
16            System.out.println(_paramResampling);
17            initParameters();      
18            _outputMapInfo.setResampling(reSamp);
19            final String prodName = _paramNewProductName.getValueAsText();
20            final String prodDesc = _paramNewProductDesc.getValueAsText();
21            final boolean includeGrids = Boolean.parseBoolean(
22                  _paramIncludeTiePointGrids.getValueAsText());
23
24            Product product2  = ProductProjectionBuilder.
25                  createProductProjection(getSourceProduct(),
26                      false, includeGrids,
27                      _outputMapInfo,
28                      prodName, prodDesc);
29            ProductIO.writeProduct(product2,  targetFilename, null);

30        } catch (IOException e) {
31            System.out.println("I/O error: " + e.getMessage());
32            e.printStackTrace();}
33        }   
34      }
35
36      public static Product getSourceProduct() {      
37          try {
38              _sourceProduct = ProductIO.readProduct(_inFile , null);
39          } catch (IOException e) {
40              System.out.println("I/O error: " + e.getMessage());
41              e.printStackTrace();
42          }
43         return _sourceProduct;
44      }
Flag Flag
RE: Programatically georeference/Project an Images
2/12/10 9:03 PM as a reply to Kabuchanga Eric.
Hi

Sorry for the late reply. But currently we are really busy to prepare the next BEAM release.
Thanks for your patience.

Now to you question. I'm a bit confused.
Why do you want georeference ENVISAT data? Normally it is already georeferenced.
If you only want to reproject it, you don't need to implement it your self.
If you are currently using BEAM 4.6.x, you can use the mapproj.bat. It is located in the bin folder of your BEAM installation.
For the usage, please see also the BEAM Help.

An automatic georeferencing of not georeferenced images is not possible
But you can use ground control points (GCPs) within VISAT (Please see: BEAM Help).

Writing ENVISAT N1 files is not supported by BEAM. You can either write your data in BEAM-DIMAP, GeoTiff or HDF.
It depends on your use case which one you choose. But please note that our product model is fully supported by BEAM-DIMAP only.

I hope this helps you.

best wishes
Marco
Flag Flag
RE: Programatically georeference/Project an Images
2/17/10 8:58 AM as a reply to Marco Peters.
I was really confused. Sorry.

ENVISAT data is of course not geo-referenced. Only geo-coded.

The parameters for a MapInfo can be derived from the e.g. the center position of the product to reproject.
Or you set fixed parameters if all products cover the same region and shall be projected to the same reference system.

Nearly all classes are located in the package
1org.esa.beam.framework.dataop.maptransf

Another useful class/method might be
1org.esa.beam.util.ProductUtils.createSuitableMapInfo(...)


best wishes
Marco
Flag Flag
RE: Programatically georeference/Project an Images
2/17/10 11:32 AM as a reply to Marco Peters.
Thank you very much Perter Macros. Even though confusion you answered my question 80%.

I managed to look at the Mapproj.bat careful in the bin folder and it will work for me. I have developed a .NET service running on our server. It has a file watcher module to watch ENVISAT data as it comes in any time of the day. The moment an image comes in, it should executes Mapproj.bat to project the image and save it another directory as a projected image. Another *.bat tool then is to read the attributes(Name, Description, Type, Date of capture, Numbers of bands ect) of the projected image and generate metadata for the particular image as an xml file for later processing to be posted in the portal.


The arguments for Mapproj.bat to project the image are defined in 3 scenario XML files. The 3 scenario XML files are;

Case 1
 1
 2
 3<?xml version="1.0" encoding="ISO-8859-1"?>
 4<RequestList>
 5    <Request type="MAP_PROJECTION">
 6
 7        <Parameter name="projection_name" value="Geographic Lat/Lon"/>
 8        <Parameter name="projection_parameters" value=""/>
 9
10        <!--
11            Resampling Method parameter:
12            Default value: NEAREST_NEIGHBOUR
13            Possible values: NEAREST_NEIGHBOUR, BILINEAR_INTERPOLATION, CUBIC_CONVOLUTION
14        -->
15        <Parameter name="resampling_method" value="NEAREST_NEIGHBOUR"/>
16
17        <!--
18            Orthorectification parameters:
19            The parameter "orthorectification" is optional. "false" is the default value.
20            The parameter "orthorectification_dem" is optional.
21        -->
22        <Parameter name="orthorectification" value="false"/>
23        <Parameter name="orthorectification_dem" value="GETASSE30"/>
24
25        <Parameter name="pixel_size_x" value="0.01"/>
26        <Parameter name="pixel_size_y" value="0.01"/>
27        <Parameter name="fit_output" value="true"/>
28
29        <Parameter name="log_to_output" value="false"/>
30        <Parameter name="log_prefix" value="mosaic"/>
31
32        <InputProduct file="D:\imageData\MER_RR__2PNPDK20090613_082458_000021622079_00465_38094_3763.N1"/>
33        <OutputProduct file="D:\imageData\projctdImg\test.dim" format="BEAM-DIMAP"/>
34    </Request>
35</RequestList>



Case2
 1
 2
 3<?xml version="1.0" encoding="ISO-8859-1"?>
 4<RequestList>
 5    <Request type="MAP_PROJECTION">
 6
 7        <Parameter name="projection_name" value="Geographic Lat/Lon"/>
 8        <Parameter name="projection_parameters" value=""/>
 9
10        <Parameter name="pixel_size_x" value="0.013115006"/>
11        <Parameter name="pixel_size_y" value="0.013115006"/>
12        <Parameter name="northing" value="-42.464428"/>
13        <Parameter name="easting" value="31.9216"/>
14        <Parameter name="output_width" value="1296"/>
15        <Parameter name="output_height" value="897"/>
16
17      <InputProduct file="D:\imageData\MER_RR__2PNPDK20090613_071742_000001572079_00464_38093_3449.N1"/>
18        <OutputProduct file="D:\imageData\projctdImg\test.dim" format="BEAM-DIMAP"/>
19
20        <Parameter name="log_to_output" value="false"/>
21        <Parameter name="log_prefix" value="mosaic"/>
22    </Request>
23</RequestList>


Case 3
 1
 2
 3
 4<?xml version="1.0" encoding="ISO-8859-1"?>
 5<RequestList>
 6    <Request type="MAP_PROJECTION">
 7
 8        <Parameter name="projection_name" value="Geographic Lat/Lon"/>
 9        <Parameter name="projection_parameters" value=""/>
10        <Parameter name="pixel_size_x" value="0.02"/>
11        <Parameter name="pixel_size_y" value="0.02"/>
12
13        <Parameter name="west_lon" value="-5.0"/>
14        <Parameter name="east_lon" value="6.0"/>
15        <Parameter name="north_lat" value="45.0"/>
16        <Parameter name="south_lat" value="33.0"/>
17
18        <Parameter name="log_to_output" value="false"/>
19        <Parameter name="log_prefix" value="mosaic"/>
20
21        <InputProduct file="D:\imageData\MER_RR__2PNPDK20090613_082458_000021622079_00465_38094_3763.N1"/>
22        <OutputProduct file="D:\imageData\projctdImg\test.dim" format="BEAM-DIMAP"/>
23
24    </Request>
25</RequestList>



My problem now is how do i get these parameters from a raw image;-

  1. projection_parameters
  2. pixel_size_x
  3. pixel_size_y
  4. west_lon
  5. east_lon
  6. north_lat
  7. south_lat
  8. center_northing
  9. center_easting


I can get the height and width of the raw image but i haven't known yet to read the above parameters from an image?

The products we receive do not cover one area, but different parts of African continent. These are level 2 MERIS, ASAR and AATSR data.
Flag Flag
RE: Programatically georeference/Project an Images
2/17/10 7:38 PM as a reply to Kabuchanga Eric.
To do this you really have to develop a little program.

To get the parameters for the MapInfo you can have a look into the following method:
1
2ProductUtils.createSuitableMapInfo(Product product,
3                                   Rectangle rect,
4                                   MapProjection mapProjection)

Maybe you can simply use it, if it fits your needs.

To get the MapProjection instance for the Geographic projection you can use the following:
1MapProjectionRegistry.getProjection(IdentityTransformDescriptor.NAME)


I hope this helps.

best wishes
Marco

p.s. My Name is Marco Peters, first name 'Marco', surname 'Peters'. Just to inform you.
But I also like the name you have created emoticon
Flag Flag
RE: Programatically georeference/Project an Images
2/18/10 12:10 PM as a reply to Marco Peters.
Hahahahaha i don't even know how i came to that.

Thank you, thats what i will do write a small program.

I will be back should i be in trouble.
Flag Flag