Exporting View as Image Help

Hello,
Here’s my situation. I’d like to use the ‘Export View as Image’ feature for cartographic output of an S1 product. I’ve coloured up some features with a couple of masks and would like to export the whole image as a GeoTIFF. Although when I try to export as a GeoTIFF file, I get the ‘Image cannot be exported’ error. I’ve read that this is due to the fact that the limit for GeoTIFF is roughly 2GB, which then necessitates the BigTIFF format. I attempted to use the File->Export->GeoTIFF/BigTIFF option, but I get a very different result (I tested it on a smaller subset and the ‘Export View as Image’ creates a GeoTIFF with RGB bands I think) So, my question is: is there a way to export my current view as a BigTIFF file? Or any advice on this matter would be great. Thanks!

The question is do you really want to have an image which is more than 2GB?
An option could be that you do a resampling to a lower resolution or cut the image into multiple pieces.
Another option is to create a band subset with just the three RGB channels and save this as BigGeoTiff. The data needs to be reprojected otherwise additional bands are added for the geo-location information. Then you you can try to create the RGB image in another software. Maybe QGIS.

Thank you @marpet for the suggestions. Let me try to rephrase the intent. We enjoy creating final cartographic output using SNAP. We use ‘Export View as Image’ for final mapping of S1 subsets when coupled with vectors. This creates high-quality raster data at the source resolution that looks just like the raster and vector data did as displayed in SNAP. We want to be able to export raster/vector “views” in SNAP but with files larger than is supported now. Our testing of the ‘Export View as Image’ suggests this routine does not switch to BigGeoTiff, when it is needed and as a result, fails. We like the ‘Export View as Image’ output approach so much, that we are considering developing this, but ask for your advice:

In your experience do you think the ‘Export View as Image’ feature could be “recreated” using other means such as the graph builder or code, in which BigGeoTiff is supported? Thanks for the input!

Nice, that you consider to help with the development. That’s great.

I checked the code for the image export. It seems that only a few lines need to be changed.
I have made this already on a branch. Would be great if you could test it. I have not. Just coded.

The branch is named mp_write_images_as_BigGeotiffs
Here you can see the changes:

Are you already familiar with building SNAP software?
If not take a look at our wiki:
Cookbook- SNAP Wiki (atlassian.net)

Other options like pconvert do not consider vectordata and layers.
But this could be implemented. pconvert would be a good place for this.
Actually we have this already listed in this issue
[SNAP-624] Turn various SNAP Desktop actions into reusable API - JIRA (atlassian.net)
as ‘multi-layer views incl. legends and export as images’.
But not only the RGB channels need to be configured but also all the layers which shall be used. To do this, some kind of configuration file is needed.

As alternative you can implement also you own little program for your specific needs.
See this:
Exporting RGB image with vector layers - development / python - STEP Forum (esa.int)

Or if you prefer Python:
snap-engine/snappy_write_image.py at 81577c9811882440a5f1b026aaacbefa5b857cfe · senbox-org/snap-engine (github.com)

Hi,

Thanks for the advice! I figured I’d start at the beginning, so I managed to test out the code in the mp_write_images_as_BigGeotiffs branch and had a couple of questions about the results.

Using a smaller image subset, I exported using the “Export View as Image” feature. The resulting image was exported as a regular GeoTiff file (used the “tifffile” Python library to confirm this). Now I was wondering, since you added “setForceBigTIFF(true)”, was the intention to always export a file as a BigGeoTiff or will it only export a BigGeoTiff if the file exceeds the size limit of a GeoTiff file?

I also attempted to use the export a larger S1 image file. I received “The image could not be exported.” error. Specifically:

In summary, it appears that the new branch you provided is not being called as the program fails before it gets there. I reviewed the code. It looks like the BufferedImage constructor in ExportImageAction.java is attempting to create a DataBufferByte using a “size” so big, that it is causing an integer overflow. We were thinking the existing BufferedImage.java (or even deeper down, Raster.java) class may be the culprit. Perhaps this could be replaced with another that supports larger images? If we are correct, then with the raster variable/library fix in hand then we can test if the new branch of code provided forces a BigTiff output. Does your assessment come to a similar conclusion?

Yes, it was intended to always export BigGeoTiff, at least for now. Should be an issue. Even smaller images can be saved as BigGeoTiff.

The export can only handle images with a maximum pixel count of 2147483647.
This is 46.340² pixels.

We have an issue for this since a while:
[SNAP-1228] Exporting large image views not possible - JIRA (atlassian.net)
Maybe the usage of a buffered images can be avoid or initialised differently.