System command calls different version of gdal

9 views (last 30 days)
I am importing .hdf files programatically and need to perform some combinations and transformations using gdal. When I do these commands from terminal (Ubuntu 20.04.2) they run fine. When I use the same command in matlab using system() I get an ERROR 4: file.hdf not recognized as a supported file format. When I check for acceptable formats using the --formats tag hdf4 and hdf5 appear in terminal but not in the Matlab system command. I then checked versions using the --versions tag and found that in terminal I get:
~$ gdalinfo --version
GDAL 3.0.4, released 2020/01/28
~$ which gdalinfo
/usr/bin/gdalinfo
In MATLAB command window I get:
>> system('gdalinfo --version');
GDAL 3.0.2, released 2019/10/28
>> system('which gdalinfo');
/usr/bin/gdalinfo
I have gone through steps to completely delete gdal from my system and confirmed that both terminal and command window return that gdal is not a command and then reinstalled but the same issue appears. I have checked the PATH variable in MATLAB and it says usr/bin is in the path. If anyone can help I would greatly appreaciate it.

Answers (1)

Sean de Wolski
Sean de Wolski on 19 Mar 2021
Edited: Sean de Wolski on 19 Mar 2021
Can you provide the full path to the gdal executable?
system('<gdalroot>/gdalinfo --version');
  1 Comment
Adam Drake
Adam Drake on 19 Mar 2021
>> system('/usr/bin/gdalinfo --version');
GDAL 3.0.2, released 2019/10/28
In Terminal:
~$ /usr/bin/gdalinfo --version
GDAL 3.0.4, released 2020/01/28

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!