[GIS] Converting Sentinel 2 jp2 bands to TIFF with gdal

gdalgdal-translate

I want to convert a .jp2 file from the Sentinel 2 project to .tif with gdal. For some bands it works (e.g. B01) and for some bands it always fails (e.g. B04). I use the sentinel public image browser data (e.g this product).

When I run gdal_translate B04.jp2 B04.tif I get the following output:

Input file size is 10980, 10980
0maximum number of samples exceeded (120560400 > 67108864)
error: cannot decode code stream
ERROR 1: B04.jp2, band 1: IReadBlock failed at X offset 0, Y offset 0

My gdal version is 2.3.0, released 2018/05/04

Best Answer

There is no issue in conversion of B04.jp2 (you posted in question) to B04.tif using the above command.

I used gdal 2.3.0 released 2018/05/04. It worked well.

Try opening the data in a viewer. It might be corrupted/not fully download.

The error IReadBlock failed generally occurs when the file is not complete.