qgreenland/util/raster.py
def gdal_edit_raster(in_filepath, *,
                     layer_cfg, gdal_edit_kwargs):
    """Overwrite in_filepath with edited metadata."""
    cmd_args_list = []
    for k, v in gdal_edit_kwargs.items():
        cmd_args_list.append(f'-{k} {v}')

    cmd_args_str = ' '.join(cmd_args_list)

    cmd = (
        f'. activate gdal && gdal_edit.py'
        f' {cmd_args_str}'
        f' {in_filepath}'
    )
    logger.debug(f'Executing gdal_edit.py command: {cmd}')

    # TODO: util func for running external cmd.
    result = subprocess.run(cmd,
                            shell=True,
                            executable='/bin/bash',
                            capture_output=True)

    if result.returncode != 0:
        raise RuntimeError(result.stderr)
Overwrite in_filepath with edited metadata.
Overwrite in_filepath with edited metadata.
Overwrite in_filepath with edited metadata .
def gdal_edit_raster(in_filepath, *,
                     layer_cfg, gdal_edit_kwargs):
    cmd_args_list = []
    for k, v in gdal_edit_kwargs.items():
        cmd_args_list.append(f'-{k} {v}')
    cmd_args_str = ' '.join(cmd_args_list)
    cmd = (
        f'. activate gdal && gdal_edit.py'
        f' {cmd_args_str}'
        f' {in_filepath}'
    )
    logger.debug(f'Executing gdal_edit.py command: {cmd}')
    result = subprocess.run(cmd,
                            shell=True,
                            executable='/bin/bash',
                            capture_output=True)
    if result.returncode != 0:
        raise RuntimeError(result.stderr)
def gdal_edit_raster ( in_filepath , * , layer_cfg , gdal_edit_kwargs ) : cmd_args_list = [ ] for k , v in gdal_edit_kwargs . items ( ) : cmd_args_list . append ( f'-{k} {v}' ) cmd_args_str = ' ' . join ( cmd_args_list ) cmd = ( f'. activate gdal && gdal_edit.py' f' {cmd_args_str}' f' {in_filepath}' ) logger . debug ( f'Executing gdal_edit.py command: {cmd}' ) result = subprocess . run ( cmd , shell = True , executable = '/bin/bash' , capture_output = True ) if result . returncode != 0 : raise RuntimeError ( result . stderr )
Overwrite in_filepath with edited metadata.
Overwrite in_filepath with edited metadata .
"""Overwrite in_filepath with edited metadata.""" # TODO: util func for running external cmd.
in_filepath
layer_cfg
gdal_edit_kwargs