[R-sig-Geo] Sentienl 2 gdal translate
Loïc Dutrieux
loic.dutrieux at conabio.gob.mx
Wed Mar 15 23:13:47 CET 2017
Hi,
I tried your code with some S2 images I had lying around, and it works
on my system. I modified it a bit to write the output layers to the same
directory and not to my working directory.
library(gdalUtils)
library(raster)
Image_Path<-'/path/to/images/'
S2_JP2_List <- list.files(Image_Path, full.names = TRUE, pattern = ".jp2$")
for (file in S2_JP2_List) {
out_file <- extension(file, 'tif')
gdal_translate(src_dataset = file, dst_dataset = out_file, ot =
"UInt16", of = "GTiff")
}
gdal has a sentinel 2 driver, but it's not extremely old, therefore it's
possible that your installation doesn't have it; you can check with:
gdal-config --formats | grep sentinel2
Cheers,
Loïc
On 15/03/17 12:49, Miguel Castro Gómez wrote:
> Hi,
>
> I have Sentinel 2 images (jp2) that I want to convert to GTiff using gdal_translate in R (from gdalutils package). Here is the code I’m using
>
> Image_Path<-“/path/to/wd“
>
> S2_JP2_List <- list.files(Image_Path, full.names = TRUE, pattern = ".jp2$")
>
> for (i in 1:length(S2_JP2_List)) {
> gdal_translate(src_dataset = S2_JP2_List[[i]], dst_dataset = paste("Band", i , "tif"), ot = "UInt16", of = “GTiff")
> }
>
> When running this code, the process starts without any error but its never ending neither producing any output
>
> I've tried to do it in gdal and the same code works, except that it is necessary to skip the default driver since it cannot manage large jp2 files.
>
> gdal_translate -of GTiff /path/to/input/S2_b1.jp2 /path/to/output/S2_b1converted.tif --config GDAL_SKIP JP2ECW
>
> Any idea how could I run this in R?
>
> Thanks
> M
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
More information about the R-sig-Geo
mailing list