[GIS] gdal_translate SENTINEL jp2 to tiff

gdalgdal-translategeotiff-tiffjpeg 2000sentinel-2

I'm trying to convert Sentinel2 jp2 image to tiff using gdal_translate. When running the code:

Miguel$ gdalinfo /Users/Miguel/Desktop/S2_b1.jp2 
Driver: JP2ECW/ERDAS JPEG2000 (SDK 5.2)
Files: /Users/Miguel/Desktop/S2_b1.jp2
Size is 1830, 1830
Coordinate System is:
PROJCS["WGS 84 / UTM zone 33N",
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0,
        AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.0174532925199433,
        AUTHORITY["EPSG","9122"]],
    AXIS["Latitude",NORTH],
    AXIS["Longitude",EAST],
    AUTHORITY["EPSG","4326"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",15],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",0],
UNIT["metre",1,
    AUTHORITY["EPSG","9001"]],
AXIS["Easting",EAST],
AXIS["Northing",NORTH],
AUTHORITY["EPSG","32633"]]
Origin = (600000.000000000000000,7000020.000000000000000)
Pixel Size = (60.000000000000000,-60.000000000000000)
Metadata:
ALL_COMMENTS=Kakadu-v7.4
Kdu-Layer-Info: log_2{Delta-D(squared-error)/Delta-L(bytes)}, L(bytes)
-192.0,  3.8e+06

COLORSPACE=GREYSCALE
COMPRESSION_RATE_TARGET=3
Corner Coordinates:
Upper Left  (  600000.000, 7000020.000) ( 16d58'56.33"E, 63d 6'56.41"N)
Lower Left  (  600000.000, 6890220.000) ( 16d55' 3.52"E, 62d 7'50.52"N)
Upper Right (  709800.000, 7000020.000) ( 19d 9'13.82"E, 63d 4' 7.06"N)
Lower Right (  709800.000, 6890220.000) ( 19d 1' 7.24"E, 62d 5' 8.11"N)
Center      (  654900.000, 6945120.000) ( 18d 1' 5.23"E, 62d36'15.28"N)
Band 1 Block=256x256 Type=UInt16, ColorInterp=Gray
Description = Grayscale
Overviews: 915x915, 457x457, 228x228
Image Structure Metadata:
NBITS=15


ns27:~ Miguel$ gdal_translate /Users/Miguel/Desktop/S2_b1.jp2       /Users/Miguel/Desktop/S2_b1tif.tif
Input file size is 1830, 1830
0

The file is created but canĀ“t be opened.

Any suggestion about how to proceed?

Best Answer

I can't reproduce your issue with GDAL 2.2-dev (yesterday's trunk version from gisinternals.com).

I downloaded a rando Sentinel2 zip file from https://scihub.copernicus.eu/dhus/#/home. It happened to be "S2A_MSIL1C_20170129T110311_N0204_R094_T31UCT_20170129T110306.zip".

I unzipped the file and changed my working directory into

C:\data\S2A_MSIL1C_20170129T110311_N0204_R094_T31UCT_20170129T110306.SA
FE\GRANULE\L1C_T31UCT_A008385_20170129T110306\IMG_DATA>

I used this command:

C:\data\sentinel\S2A_MSIL1C_20170129T110311_N0204_R094_T31UCT_20170129T110306.SA
FE\GRANULE\L1C_T31UCT_A008385_20170129T110306\IMG_DATA>gdal_translate T31UCT_201
70129T110311_B08.jp2 c:\data\sentinel.tif
Input file size is 10980, 10980
0...10...20...30...40...50...60...70...80...90...100 - done.

Gdalinfo report from the resulting tiff file:

C:\data>gdalinfo sentinel.tif
Driver: GTiff/GeoTIFF
Files: sentinel.tif
Size is 10980, 10980
Coordinate System is:
PROJCS["WGS 84 / UTM zone 31N",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",3],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AXIS["Easting",EAST],
    AXIS["Northing",NORTH],
    AUTHORITY["EPSG","32631"]]
Origin = (300000.000000000000000,5800020.000000000000000)
Pixel Size = (10.000000000000000,-10.000000000000000)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (  300000.000, 5800020.000) (  0d 3'56.87"E, 52d18'50.48"N)
Lower Left  (  300000.000, 5690220.000) (  0d 7'45.16"E, 51d19'40.99"N)
Upper Right (  409800.000, 5800020.000) (  1d40'33.33"E, 52d20'35.00"N)
Lower Right (  409800.000, 5690220.000) (  1d42'16.48"E, 51d21'21.89"N)
Center      (  354900.000, 5745120.000) (  0d53'37.96"E, 51d50'16.88"N)
Band 1 Block=10980x1 Type=UInt16, ColorInterp=Gray
  Image Structure Metadata:
    NBITS=15
Related Question