Ursulka Siete
Ursulka Siete

Reputation: 153

How to read JPEG2000 of Sentinel-2 data in R

I am trying to use the rgdal package to open multiple Sentinel-2 data of JPEG2000 format.

The issue I am running into is:

Error in .local(.Object, ...) : 
d:/data/T35SMD_20161227T091402_B01.jp2' not recognised as a supported file format.

Although, I have updated my installation of the rgdal package and use updated gdal binaries that support JPEG2000, which had support introduced in v1.9.0.

rgdal: version: 1.2-5, (SVN revision 648)
Loaded GDAL runtime: GDAL 2.0.1, released 2015/09/15

When I perform gdalDrivers() command, the entry for JPG2000 is not listed there among other drivers.

Can anyone please tell me how could I solve this problem? I have plenty of S-2 data and converting them to tiff in QGIS or any similar program is no option for me.

I have also found few similar questions on this theme (c.f. open jpeg2000 sentinel 2 in r), however it seems there is no straight answer yet.

Upvotes: 2

Views: 1516

Answers (1)

Benjamin
Benjamin

Reputation: 11860

Use the command-line utility gdal_translate, as documented here: http://www.gdal.org/frmt_sentinel2.html. You will have a lot more flexibility, and likely better speed and memory handling. Example that is given there is:

gdal_translate SENTINEL2_L1C:S2A_OPER_MTD_SAFL1C_PDMC_20150818T101440_R022_V20150813T102406_20150813T102406.xml:10m:EPSG_32632 10m.tif -co TILED=YES --config GDAL_CACHEMAX 1000 --config GDAL_NUM_THREADS 2

There's not really a solid argument for doing that much heavy lifting in R, especially through something that is essentially a wrapper.

Upvotes: 2

Related Questions