ESA-PhiLab / OpenSarToolkit

High-level functionality for the inventory, download and pre-processing of Sentinel-1 data in the python language.
https://opensartoolkit.readthedocs.io/en/latest/
MIT License
206 stars 52 forks source link

stop importing gdal #65

Closed 12rambau closed 2 years ago

12rambau commented 2 years ago

Based on gdal documentation and the fact that we request gdal>=2 in the setup.py we can safely drop the usage of:

import gdal
import ogr

The binding using osgeo module is available since gdal 1.7

from osgeo import gdal
from osgeo import ogr

Additionally, there are five compatibility modules that are included but provide notices to state that they are deprecated and will be going away. If you are using GDAL 1.7 bindings, you should update your imports to utilize the usage above, but the following will work until GDAL 3.1.

12rambau commented 2 years ago

let's go one step further. @BuddyVolly know how much I hate the gdal lib mainly because installing it is a nighmare.

We only use it for 3 different actions in the lib:

It means even though I hate this lib, we cannot yet fully drop it. But writting vrt is a simple task that didn't evolve since the format was created (as it's mainly doing a gdalinfo and organising all the information in a xml file) so i assume that the version of gdal is unrelevant.

That would allow ANY version of gdal to work. So instead of trying to find the apropriate version of gdal or a way to install gdal on any platform what about we simply test gdal version before build as a requirement (and if it's < 1.7 we refuse it) that the user need to solve BEFORE installing OST ?

If you don't agree with the statement "installing it is a nighmare" look at heroku distributions. They have a specific build for GIS and it embeds GDAL==3.2.3 and manage the installation for you, same for conda-forge.

KBodolai commented 2 years ago

ah, the good old installing GDAL issue. So far in some of my work projects, we've treated it as a pre-requisite and have given up on integrating it in the install process.

I've sometimes had issues installing rasterio if gdal is not present, so not sure how problematic this will be.

That being said, installing gdal with conda is normally very straightforward and I haven't had issues with it in either mac or linux. SO, I'm happy with having it as a pre-requisite for pip installs.