def test_query_and_download(): os.chdir(os.path.dirname(os.path.abspath(__file__))) test_conf = load_test_conf() user = test_conf["sent_2"]["user"] passwd = test_conf["sent_2"]["pass"] images = pyeo.sent2_query(test_conf["sent_2"]["user"], test_conf["sent_2"]["pass"], "test_data/marque_de_com_really_simple.geojson", "20180101", "20180110") assert len(images) > 0 try: shutil.rmtree("test_outputs/L1") except FileNotFoundError: pass os.mkdir("test_outputs/L1") pyeo.download_s2_data(images, "test_outputs/L1", source='scihub', user=user, passwd=passwd) for image_id in images: assert os.path.exists( "test_outputs/L1/{}".format(images[image_id]['title'] + ".SAFE"))
# Download and build the initial composite. Does not do by default if args.build_composite: if args.do_download or do_all: log.info( "Downloading for initial composite between {} and {} with cloud cover <= ()" .format(composite_start_date, composite_end_date, cloud_cover)) composite_products = pyeo.check_for_s2_data_by_date( aoi_path, composite_start_date, composite_end_date, conf, cloud_cover=cloud_cover) pyeo.download_s2_data(composite_products, composite_l1_image_dir, composite_l2_image_dir, source=args.download_source, 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,
# Download and build the initial composite. Does not do by default if args.build_composite: if args.do_download or do_all: log.info( "Downloading for initial composite between {} and {} with cloud cover <= ()" .format(composite_start_date, composite_end_date, cloud_cover)) composite_products = pyeo.check_for_s2_data_by_date( aoi_path, composite_start_date, composite_end_date, conf, cloud_cover=cloud_cover) pyeo.download_s2_data(composite_products, 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,
l1_image_path = os.path.join(project_root, r"images/L1") l2_image_path = os.path.join(project_root, r"images/L2") planet_image_path = os.path.join(project_root, r"images/planet") merged_image_path = os.path.join(project_root, r"images/merged") stacked_image_path = os.path.join(project_root, r"images/stacked") mosaic_image_path = os.path.join(project_root, r"images/mosaic") catagorised_image_path = os.path.join(project_root, r"output/classified") probability_image_path = os.path.join(project_root, r"output/probabilities") # Query and download if args.do_download or do_all: products = pyeo.check_for_s2_data_by_date(aoi_path, start_date, end_date, conf) log.info("Downloading") 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,