Combination View Flat View Tree View
Threads [ Previous | Next ]
RE: mosaic with a hundred TiFF(landset 8) images
hi, everyone! I just started learning beam,
i have two qustions,one question .i want to make a mosaic with a hundred Tiff (landset 8) by beam api,can i achieve it?if it can be achieved,If it's convenient for you,Please tell how to achieve that by beam api,and i use java to complete it.
the second question.when i use two landset8 images to do mosaic, band.ensureRasterData() reports an java.langoutofmemoryerror : java heap space;and i have enlarged the size of jvm to solve this question ,but it does not help, i think it is because the data is large,because when i use two landset5 ,it runs very well ,the codes is as follows:
1   w=18611;h=66081;
2        Product mosaic=new Product("mosaic", "GeoTIFF", w, h);
3        Band band=new Band("band_1", sourceBand.getGeophysicalDataType(), w, h);
4        band.ensureRasterData();
5        mosaic.addBand(band);
6                         mosaic.setGeoCoding(crsgeocoding);
7                        return mosaic;

but i have no idea about this, help, please!

any idea will be deeply appreciated.
thanks in advance
Flag Flag
RE: mosaic with a hundred TiFF(landset 8) images
8/31/17 1:44 PM as a reply to xu bo.
Great that you want to learn BEAM, but unfortunately I have to disappoint you.
BEAM is not further developed and maintenance is lowered to a minimum, as stated on the front page.
But you can switch to SNAP. It is the successor of BEAM. So you should use this API.

To create a mosaic of you don't need to use the API.
You can simply do it on the command line by call the gpt tool (in the bin folder of the installation directory).
A first introduction is given here:

And if you want to use the API, you should use GPF and the operator we already provide.
The code would like this:
 2Map parameters = new HashMap();
 3parameters.put("ParamName", paramValue); // the available paramters can be looked up by calling "gpt Mosaic -h". This will show you the documentaion
 5Product p1 = ProductIO.readProduct("c:\Path\to\file")
 6Product[] sources = new Product[]{p1};
 9Product mosaic = GPF.createProduct("Mosaic", parameters, sources);
10ProductIO.writeProduct(mosaic, "c:\path\to\outfile", "BEAM-DIMAP") // instead of BEAM-DIMAP you can use GeoTIFF-BigTIFF, or something else.

To leave a comment on your code snippet
In your code snipped the full raster of 18611x66081 is loaded into the memory at once by calling ensureRasterData(). This is not good. It is your target raster and there is no data yet. You can fill it later consecutivly.
Anyway, the before mentioned ways are prevered.
Flag Flag
RE: mosaic with a hundred TiFF(landset 8) images
9/6/17 3:55 AM as a reply to Marco Peters.
hi, Marco Peters
I'm glad to receive your answer and advises, it is helpful to me .however ,i have other three question to consult you:
1.if i use SNAP,i also want to make a mosaic with a hundred Tiff (landset 8) by api,Can the method of band.ensureRasterData() avoid the error of java.langoutofmemoryerror : java heap space? it is writing to the hard disk instead of memory?
2.i find the snap has two sets of API .it's SNAP Engine API Documentation and SNAP Desktop API Documentation. What's the difference between the API? where can i get the jar pachage(java).
3 if i turn to SNAP, Are there tutorials or examples of snap?
thank you in advance!
best wishes to you!
xu bo

Flag Flag
RE: mosaic with a hundred TiFF(landset 8) images
9/6/17 9:25 AM as a reply to xu bo.
  1. The ensure raster creates the memory representation for the whole raster at once. Not calling it will probably avoid the OutOfMemoryError.
    If you have the data at hand you can use Band.writeRasterData() or Band.writePixels() to save the data to disk.
  2. The Engine API is the core of SNAP. It contains all the basic functionality. The Desktop API, contains only the GUI stuff. The API for the Desktop application.
  3. You can find tutorials in our wiki: Developer Guide
Flag Flag


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: