mrayson / suntans_tutorial

Tutorial for setting up the SUNTANS ocean model (github.com/ofringer/suntans) with examples
6 stars 1 forks source link

Proper usage of GDAL and OGR #3

Open iosonobert opened 3 years ago

iosonobert commented 3 years ago

Could be wrong here, but Kelly's GDAL issue could be improper/deprecated usage of GDAL by SFODA. Details:

Installed yesterday on a kubuntu VM and with problems except that I made the VM too small.

Reinstalled everything today on a larger VM. I believed I followed the same steps, but now may well be having the same issue as Kelly.

It seems that after you install the GDAL development libraries and then run:

 pip3 install GDAL=3.2.1

It seems this creates the osgeo package in your .../python*/dist-packages directory

The proper import of gdal and ogr should then be

 from osgeo import gdal, ogr

The usage

 import gdal
 import ogr

Appears to be deprecated.

The question remains as to why it works for everyone else (and worked for me last night) but not for Kelly (and not for me today). I believe I have this answer also. For whatever reason, the GDAL install I did yesterday appears to have imported version 3.0.4, but the one I did today has imported 3.2.1. I believe the older version does add the older python bindings such that 'import gdal' and 'import ogr' work fine. My guess is Kelly has a newer version of GDAL.

I think if Matt updates the sfoda code we'll be good to install whatever version of GDAL we choose. Alternately we need to update the suntans_tutorial documentation to specify install for an older version of GDAL. I suspect the former is easier.

Cheers, Andrew