Beispiel #1
0
def test_merging():
    os.chdir(os.path.dirname(os.path.abspath(__file__)))
    try:
        os.remove(
            "test_outputs/S2A_MSIL2A_20180329T171921_N0206_R012_T13QFB_20180329T221746.tif"
        )
        os.remove(
            "test_outputs/S2B_MSIL2A_20180103T172709_N0206_R012_T13QFB_20180103T192359.tif"
        )
        os.remove(
            "test_outputs/S2A_MSIL2A_20180329T171921_N0206_R012_T13QFB_20180329T221746.msk"
        )
        os.remove(
            "test_outputs/S2B_MSIL2A_20180103T172709_N0206_R012_T13QFB_20180103T192359.msk"
        )
    except FileNotFoundError:
        pass
    pyeo.preprocess_sen2_images("test_data/L2/",
                                "test_outputs/",
                                "test_data/L1/",
                                buffer_size=5)
    assert os.path.exists(
        "test_outputs/S2A_MSIL2A_20180329T171921_N0206_R012_T13QFB_20180329T221746.tif"
    )
    assert os.path.exists(
        "test_outputs/S2B_MSIL2A_20180103T172709_N0206_R012_T13QFB_20180103T192359.tif"
    )
    assert os.path.exists(
        "test_outputs/S2A_MSIL2A_20180329T171921_N0206_R012_T13QFB_20180329T221746.msk"
    )
    assert os.path.exists(
        "test_outputs/S2B_MSIL2A_20180103T172709_N0206_R012_T13QFB_20180103T192359.msk"
    )
Beispiel #2
0
                                  composite_l1_image_dir,
                                  composite_l2_image_dir,
                                  source='scihub',
                                  user=sen_user,
                                  passwd=sen_pass)
        if args.do_preprocess or do_all:
            log.info("Preprocessing composite products")
            pyeo.atmospheric_correction(composite_l1_image_dir,
                                        composite_l2_image_dir,
                                        sen2cor_path,
                                        delete_unprocessed_image=False)
        if args.do_merge or do_all:
            log.info("Aggregating composite layers")
            pyeo.preprocess_sen2_images(composite_l2_image_dir,
                                        composite_merged_dir,
                                        composite_l1_image_dir,
                                        cloud_certainty_threshold,
                                        epsg=epsg,
                                        buffer_size=5)
        log.info("Building initial cloud-free composite")
        pyeo.composite_directory(composite_merged_dir, composite_dir)

    # Query and download all images since last composite
    if args.do_download or do_all:
        products = pyeo.check_for_s2_data_by_date(aoi_path,
                                                  start_date,
                                                  end_date,
                                                  conf,
                                                  cloud_cover=cloud_cover)
        log.info("Downloading")
        pyeo.download_s2_data(products,
                              l1_image_dir,
Beispiel #3
0
        pyeo.download_s2_data(products, l1_image_path)

    # Atmospheric correction
    if args.do_preprocess or do_all:
        log.info("Applying sen2cor")
        pyeo.atmospheric_correction(l1_image_path,
                                    l2_image_path,
                                    sen2cor_path,
                                    delete_unprocessed_image=False)

    # Merging / Aggregating layers into single image
    if args.do_merge or do_all:
        log.info("Cleaning L2A directory")
        pyeo.clean_l2_dir(l2_image_path, resolution="10m", warning=False)
        log.info("Aggregating layers")
        pyeo.preprocess_sen2_images(l2_image_path, merged_image_path,
                                    cloud_certainty_threshold)

    # Stack layers
    if args.do_stack or do_all:
        log.info("Stacking before and after images")
        pyeo.create_new_stacks(merged_image_path, stacked_image_path)

    # Mosaic stacked layers
    if args.do_stack or do_all:
        log.info("Mosaicking stacked multitemporal images across tiles")
        pyeo.mosaic_images(stacked_image_path,
                           mosaic_image_path,
                           format="GTiff",
                           datatype=gdal.GDT_Int32,
                           nodata=0)