Exemplo n.º 1
0
def process_image(path, bands=None, verbose=False, pansharpen=False, force_unzip=None):
    """ Handles constructing and image process.

    :param path:
        The path to the image that has to be processed
    :type path:
        String
    :param bands:
        List of bands that has to be processed. (optional)
    :type bands:
        List
    :param verbose:
        Sets the level of verbosity. Default is False.
    :type verbose:
        boolean
    :param pansharpen:
        Whether to pansharpen the image. Default is False.
    :type pansharpen:
        boolean

    :returns:
        (String) path to the processed image
    """
    try:
        bands = convert_to_integer_list(bands)
        p = Process(path, bands=bands, verbose=verbose, force_unzip=force_unzip)
    except IOError:
        exit("Zip file corrupted", 1)
    except FileDoesNotExist as e:
        exit(e.message, 1)

    return p.run(pansharpen)
Exemplo n.º 2
0
def process_image(path, bands=None, verbose=False, pansharpen=False):
    try:
        bands = convert_to_integer_list(bands)
        p = Process(path, bands=bands, verbose=verbose)
    except IOError:
        exit("Zip file corrupted", 1)
    except FileDoesNotExist as e:
        exit(e.message, 1)

    return p.run(pansharpen)
Exemplo n.º 3
0
def process_image(path, bands=None, verbose=False, pansharpen=False):
    try:
        bands = convert_to_integer_list(bands)
        p = Process(path, bands=bands, verbose=verbose)
    except IOError:
        exit("Zip file corrupted", 1)
    except FileDoesNotExist as e:
        exit(e.message, 1)

    return p.run(pansharpen)
Exemplo n.º 4
0
def process_image(path,
                  bands=None,
                  verbose=False,
                  pansharpen=False,
                  force_unzip=None):
    """ Handles constructing and image process.

    :param path:
        The path to the image that has to be processed
    :type path:
        String
    :param bands:
        List of bands that has to be processed. (optional)
    :type bands:
        List
    :param verbose:
        Sets the level of verbosity. Default is False.
    :type verbose:
        boolean
    :param pansharpen:
        Whether to pansharpen the image. Default is False.
    :type pansharpen:
        boolean

    :returns:
        (String) path to the processed image
    """
    try:
        bands = convert_to_integer_list(bands)
        p = Process(path,
                    bands=bands,
                    verbose=verbose,
                    force_unzip=force_unzip)
    except IOError:
        exit("Zip file corrupted", 1)
    except FileDoesNotExist as e:
        exit(e.message, 1)

    return p.run(pansharpen)
Exemplo n.º 5
0
def process_image(path, bands=None, verbose=False, pansharpen=False, force_unzip=None, ndvi=False, cloudmask=False):
    """ Handles constructing and image process.

    :param path:
        The path to the image that has to be processed
    :type path:
        String
    :param bands:
        List of bands that has to be processed. (optional)
    :type bands:
        List
    :param verbose:
        Sets the level of verbosity. Default is False.
    :type verbose:
        boolean
    :param pansharpen:
        Whether to pansharpen the image. Default is False.
    :type pansharpen:
        boolean

    :returns:
        (String) path to the processed image
    """
    try:
        bands = convert_to_integer_list(bands)

        if isinstance(ndvi, str):
            p = Process(path, bands=[4,5], verbose=verbose, force_unzip=force_unzip)
        else:
            p = Process(path, bands=bands, verbose=verbose, force_unzip=force_unzip)
    except IOError:
        exit("Zip file corrupted", 1)
    except FileDoesNotExist as e:
        exit(e.message, 1)
    if isinstance(ndvi, str):
        out=[p.run_ndvi(mode=ndvi,cmask=cloudmask)]
    else:
        out=[p.run_rgb(pansharpen)]
    return out
Exemplo n.º 6
0
def main(args):
    """
    Main function - launches the program
    """

    v = VerbosityMixin()

    if args:
        if args.subs == 'process':
            verbose = True if args.verbose else False
            try:
                bands = convert_to_integer_list(args.bands)
                p = Process(args.path, bands=bands, verbose=verbose)
            except IOError:
                exit("Zip file corrupted", 1)
            except FileDoesNotExist as e:
                exit(e.message, 1)

            stored = p.run(args.pansharpen)

            exit("The output is stored at %s" % stored)

        elif args.subs == 'search':

            try:
                if args.start:
                    args.start = reformat_date(parse(args.start))
                if args.end:
                    args.end = reformat_date(parse(args.end))
            except (TypeError, ValueError):
                exit("You date format is incorrect. Please try again!", 1)

            s = Search()

            try:
                lat = float(args.lat) if args.lat else None
                lon = float(args.lon) if args.lon else None
            except ValueError:
                exit("The latitude and longitude values must be valid numbers",
                     1)

            result = s.search(paths_rows=args.pathrow,
                              lat=lat,
                              lon=lon,
                              limit=args.limit,
                              start_date=args.start,
                              end_date=args.end,
                              cloud_max=args.cloud)

            if result['status'] == 'SUCCESS':
                v.output('%s items were found' % result['total'],
                         normal=True,
                         arrow=True)
                if result['total'] > 100:
                    exit('Over 100 results. Please narrow your search', 1)
                else:
                    v.output(json.dumps(result, sort_keys=True, indent=4),
                             normal=True,
                             color='green')
                    exit('Search completed!')
            elif result['status'] == 'error':
                exit(result['message'], 1)
        elif args.subs == 'download':
            d = Downloader(download_dir=args.dest)
            try:
                if d.download(args.scenes,
                              convert_to_integer_list(args.bands)):
                    exit('Download Completed', 0)
            except IncorrectSceneId:
                exit('The SceneID provided was incorrect', 1)
Exemplo n.º 7
0
def main(args):
    """
    Main function - launches the program
    """

    v = VerbosityMixin()

    if args:
        if args.subs == 'process':
            verbose = True if args.verbose else False
            try:
                bands = convert_to_integer_list(args.bands)
                p = Process(args.path, bands=bands, verbose=verbose)
            except IOError:
                exit("Zip file corrupted", 1)
            except FileDoesNotExist as e:
                exit(e.message, 1)

            stored = p.run(args.pansharpen)

            exit("The output is stored at %s" % stored)

        elif args.subs == 'search':

            try:
                if args.start:
                    args.start = reformat_date(parse(args.start))
                if args.end:
                    args.end = reformat_date(parse(args.end))
            except (TypeError, ValueError):
                exit("You date format is incorrect. Please try again!", 1)

            s = Search()

            try:
                lat = float(args.lat) if args.lat else None
                lon = float(args.lon) if args.lon else None
            except ValueError:
                exit("The latitude and longitude values must be valid numbers", 1)

            result = s.search(paths_rows=args.pathrow,
                              lat=lat,
                              lon=lon,
                              limit=args.limit,
                              start_date=args.start,
                              end_date=args.end,
                              cloud_max=args.cloud)

            if result['status'] == 'SUCCESS':
                v.output('%s items were found' % result['total'], normal=True, arrow=True)
                if result['total'] > 100:
                    exit('Over 100 results. Please narrow your search', 1)
                else:
                    v.output(json.dumps(result, sort_keys=True, indent=4), normal=True, color='green')
                    exit('Search completed!')
            elif result['status'] == 'error':
                exit(result['message'], 1)
        elif args.subs == 'download':
            d = Downloader(download_dir=args.dest)
            try:
                if d.download(args.scenes, convert_to_integer_list(args.bands)):
                    exit('Download Completed', 0)
            except IncorrectSceneId:
                exit('The SceneID provided was incorrect', 1)