EOX GitLab Instance

Skip to content
Snippets Groups Projects
Commit ae754ca1 authored by Fabian Schindler's avatar Fabian Schindler
Browse files

Uniform GDAL initialization

parent d0a5482b
No related branches found
No related tags found
No related merge requests found
......@@ -6,8 +6,6 @@ from glob import glob
import shutil
import logging
from osgeo import gdal, osr
from ..util import replace_ext
......
......@@ -5,7 +5,7 @@ from glob import glob
import shutil
from typing import List, Tuple
from osgeo import gdal, osr
from ..util import gdal, osr
logger = logging.getLogger(__name__)
......@@ -55,11 +55,9 @@ def gcp_georef(input_filename: os.PathLike, target_filename: os.PathLike, order:
gdal.Warp(
target_filename,
input_filename,
options=gdal.WarpOptions(
polynomialOrder=order,
dstSRS=projection,
tps=tps,
)
polynomialOrder=order,
dstSRS=projection,
tps=tps,
)
def rpc_georef(input_filename: os.PathLike, target_filename: os.PathLike, rpc_file_template: str='{fileroot}.RPC', warp_options: dict=None):
......
......@@ -3,9 +3,7 @@ from os.path import join, basename
from glob import glob
from uuid import uuid4
from osgeo import gdal
from ..util import replace_ext
from ..util import replace_ext, gdal
def output_step(source_dir: os.PathLike, target_dir: os.PathLike, options: dict=None):
......
......@@ -4,9 +4,8 @@ from itertools import groupby
import re
from glob import glob
from typing import List
from osgeo import gdal
from ..util import replace_ext
from ..util import replace_ext, gdal
def stack_bands_step(source_dir: os.PathLike, target_dir: os.PathLike, group_by: str=None, sort_by: str=None, order: List[str]=None):
......
......@@ -3,12 +3,7 @@ from os.path import join, splitext, basename, dirname
from glob import glob
from typing import Dict
from osgeo import gdal
from ..util import replace_ext
gdal.UseExceptions()
from ..util import replace_ext, gdal
def extract_subdataset_step(source_dir: os.PathLike, target_dir: os.PathLike, data_file_glob: str, subdataset_types: Dict[str, str]=None):
......
......@@ -3,6 +3,20 @@ from os.path import splitext
from contextlib import contextmanager
from tempfile import TemporaryDirectory, mkdtemp
try:
from osgeo import gdal
except ImportError:
import gdal
gdal.UseExceptions()
try:
from osgeo import osr
except ImportError:
import osr
osr.UseExceptions()
def replace_ext(filename: os.PathLike, new_ext: str, force_dot: bool=True) -> os.PathLike:
return splitext(filename)[0] + ('' if new_ext.startswith('.') or not force_dot else '.') + new_ext
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment