1

I'm an Ubuntu 20.04 user with all configured to use .ecw raster format. I can read these files in QGIS (3.10) and work with them without a problem. This is what I get in console:

$ gdalinfo --version
GDAL 3.0.4, released 2020/01/28

$ gdalinfo --formats | grep -i ecw
ECW -raster- (rw+): ERDAS Compressed Wavelets (SDK 5.4)
JP2ECW -raster,vector- (rw+v): ERDAS JPEG2000 (SDK 5.4)

The issue here is that I'm trying to perform some processes with this files within R but it seems that .ecw are not working and I don't know what to do.

> gdalbuildvrt(gdalfile = "PNOA_MA_OF_ETRS89_HU29_h50_0151.ecw", output.vrt = "dem.vrt")

ERROR 4: `PNOA_MA_OF_ETRS89_HU29_h50_0151.ecw' not recognized as a supported file format.
Warning 1: Can't open PNOA_MA_OF_ETRS89_HU29_h50_0151.ecw. Skipping it
NULL
Warning message:
In system(cmd, intern = TRUE) :
  comando ejecutado '"/usr/local/bin/gdalbuildvrt" "dem.vrt" "PNOA_MA_OF_ETRS89_HU29_h50_0151.ecw"' tiene estatus 1

What could I check? I prefer any solution that downgrading the gdal version to 2.4 (as is Ubuntu is quite complex to make it all work and that will brake other things for sure...).

  • 1
    It looks like your command line gdalinfo and the gdalbuildvrt that R is finding might coming from different GDAL installations. What does which gdalbuildvrt say on the command line? Can you run gdalbuildvrt "dem.vrt" "PNOA_MA_OF_ETRS89_HU29_h50_0151.ecw"' tiene estatus 1 on the command line (from where that .ecw is)? – Spacedman May 20 at 11:37
  • 2
    You might be able to tell R to use a different GDAL via gdal_setInstallation, or possibly deleting the one that has put the binary for gdalbuildvrt in /usr/local/bin/ - but make sure nothing else is using it first. – Spacedman May 20 at 11:38
  • I tried to execute gdalbuildvrt "dem.vrt" "PNOA_MA_OF_ETRS89_HU29_h50_0151.ecw" in console and It worked perfectly. Something must be happening with the gdal installation R is refering. I'm not sure what should I change or how to set it. Where is the usual gdal installation in linux ? – César Arquero May 23 at 17:49
  • 1
    You can get a list of possible gdal installations for gdalUtils here: getOption("gdalUtils_gdalPath"). Check the $path element of each element in that list. Add the information I asked in my first comment about which to your question. You need to tell gdalUtils to use the right gdal. – Spacedman May 23 at 17:56
  • getOption("gdalUtils_gdalPath") returns this in $path -->[1] "/usr/local/bin/". which gdalbuildvrt returns this --> Error: unexpected symbol in "which gdalbuildvrt" – César Arquero May 23 at 22:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.