hubflow.core raster output format

Issue #224 resolved
Benjamin Jakimow created an issue

If not defined explicitly, hubflow raster outputs should meet the outputs file extention.

For example if an an output raster path is defined as file.tiff, the hubflow.core.GTiffDriver() RasterDriver should be choosen to write the raster instead the default hubflow.core.ENVIBSQDriver()

The applyer functions might consider this logic:

def guessRasterDriver(path:str)->hubflow.core.RasterDriver:
    """
    Converts a file path into the corresponding a raster driver
    :param path: str, file path
    :return: hubflow.core.RasterDriver, ENVIBSQDriver by default.
    """
    assert isinstance(path, str)

    if re.search(r'\.bsq$', path, re.I):
        return hubflow.core.ENVIBSQDriver()
    elif re.search(r'\.bil$', path, re.I):
        return hubflow.core.ENVIBILDriver()
    elif re.search(r'\.bip$', path, re.I):
        return hubflow.core.ENVIBIPDriver()
    elif re.search(r'\.g?tiff?$', path, re.I):
        return hubflow.core.GTiffDriver()
    elif re.search(r'\.vrt$', path,  re.I):
        return hubflow.core.VRTDriver()
    elif re.search(r'\.(img|hfa)', path , re.I):
        return hubflow.core.ErdasDriver()

    return hubflow.core.ENVIBSQDriver()

Comments (3)

  1. Log in to comment