Converting Sentinel 2 jp2 bands to TIFF with gdal

by T. Monroe   Last Updated July 13, 2018 07:22 AM

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

Answers 1

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.
June 11, 2018 14:55 PM

Related Questions

When should I use gdal_merge?

Updated February 22, 2018 16:22 PM

Can I change the pixel sizes in a world file?

Updated July 03, 2018 02:22 AM