|
1810 | 1810 | "\n",
|
1811 | 1811 | "intersect_polygons_subset_filename = TEST_TMP_DIR / \"intersecting_polygon_grid_10km_subset.gpkg\"\n",
|
1812 | 1812 | "print(\"Starting intersect selection\")\n",
|
1813 |
| - "intersect_polygons_subset = select_polygons_by_location(intersecting_polygons, s2_grid_subset, predicate=\"within\",\n", |
1814 |
| - " num_of_workers=4)\n", |
| 1813 | + "intersect_polygons_subset = select_polygons_by_location(\n", |
| 1814 | + " intersecting_polygons, s2_grid_subset, predicate=\"within\", num_of_workers=4\n", |
| 1815 | + ")\n", |
1815 | 1816 | "# intersect_polygons_subset = gpd.read_file(intersect_polygons_subset_filename)\n",
|
1816 | 1817 | "\n",
|
1817 | 1818 | "# Optionally save to a new file\n",
|
|
1842 | 1843 | "vector_column_name = \"s2_tiles\"\n",
|
1843 | 1844 | "\n",
|
1844 | 1845 | "# Initiating our client\n",
|
1845 |
| - "best_products_client = BestProductsForFeatures(sentinel2_tiling_grid=s2_grid_subset,\n", |
1846 |
| - " sentinel2_tiling_grid_column=s2_feature_name_columns,\n", |
1847 |
| - " vector_features=intersect_polygons_subset,\n", |
1848 |
| - " vector_features_column=vector_column_name,\n", |
1849 |
| - " max_cloud_cover=15)" |
| 1846 | + "best_products_client = BestProductsForFeatures(\n", |
| 1847 | + " sentinel2_tiling_grid=s2_grid_subset,\n", |
| 1848 | + " sentinel2_tiling_grid_column=s2_feature_name_columns,\n", |
| 1849 | + " vector_features=intersect_polygons_subset,\n", |
| 1850 | + " vector_features_column=vector_column_name,\n", |
| 1851 | + " max_cloud_cover=15,\n", |
| 1852 | + ")" |
1850 | 1853 | ]
|
1851 | 1854 | },
|
1852 | 1855 | {
|
|
1970 | 1973 | "\n",
|
1971 | 1974 | "best_results_path = TEST_TMP_DIR / \"vector_tiles_with_s2tiles_subset.gpkg\"\n",
|
1972 | 1975 | "best_results = best_products_client.select_best_products_per_feature()\n",
|
1973 |
| - "to_geopackage(best_results, best_results_path)\n" |
| 1976 | + "to_geopackage(best_results, best_results_path)" |
1974 | 1977 | ]
|
1975 | 1978 | },
|
1976 | 1979 | {
|
|
2201 | 2204 | "download_directory = TEST_TMP_DIR / \"example_s2_download_and_processing\"\n",
|
2202 | 2205 | "\n",
|
2203 | 2206 | "for p in product_list:\n",
|
2204 |
| - " processed_product = download_and_process_sentinel2_asset(product_id=p,\n", |
2205 |
| - " product_bands=bands,\n", |
2206 |
| - " base_directory=download_directory,\n", |
2207 |
| - " target_projection=5070)\n", |
| 2207 | + " processed_product = download_and_process_sentinel2_asset(\n", |
| 2208 | + " product_id=p, product_bands=bands, base_directory=download_directory, target_projection=5070\n", |
| 2209 | + " )\n", |
2208 | 2210 | "\n",
|
2209 | 2211 | " product_asset_list.append(processed_product)"
|
2210 | 2212 | ]
|
|
2238 | 2240 | "source": [
|
2239 | 2241 | "for p in product_asset_list:\n",
|
2240 | 2242 | " print(f\"Asset ID : [{p.asset_id}]\")\n",
|
2241 |
| - " print(f\"Reprojected ID path : \\n[{p.reprojected_asset_path}]\\n\")\n" |
| 2243 | + " print(f\"Reprojected ID path : \\n[{p.reprojected_asset_path}]\\n\")" |
2242 | 2244 | ]
|
2243 | 2245 | },
|
2244 | 2246 | {
|
|
2255 | 2257 | "source": [
|
2256 | 2258 | "# Here, we are creating a new Asset object simply for convenience, from the printed outputs above\n",
|
2257 | 2259 | "\n",
|
2258 |
| - "product = Asset(asset_id=\"S2A_MSIL2A_20240705T185921_R013_T10SDJ_20240706T050346\",\n", |
2259 |
| - " reprojected_asset=download_directory / \"S2A_MSIL2A_20240705T185921_R013_T10SDJ_20240706T050346_reprojected.tif\", )" |
| 2260 | + "product = Asset(\n", |
| 2261 | + " asset_id=\"S2A_MSIL2A_20240705T185921_R013_T10SDJ_20240706T050346\",\n", |
| 2262 | + " reprojected_asset=download_directory / \"S2A_MSIL2A_20240705T185921_R013_T10SDJ_20240706T050346_reprojected.tif\",\n", |
| 2263 | + ")" |
2260 | 2264 | ]
|
2261 | 2265 | },
|
2262 | 2266 | {
|
|
2298 | 2302 | }
|
2299 | 2303 | ],
|
2300 | 2304 | "source": [
|
2301 |
| - "\n", |
2302 | 2305 | "s2_product_id = product.asset_id\n",
|
2303 | 2306 | "product_path = product.reprojected_asset_path\n",
|
2304 | 2307 | "product_id_series = group_by_product[group_by_product[\"best_s2_product_id\"] == s2_product_id]\n",
|
|
2340 | 2343 | }
|
2341 | 2344 | ],
|
2342 | 2345 | "source": [
|
2343 |
| - "clip_list = clip_raster_with_polygon(raster_image=product_path,\n", |
2344 |
| - " polygon_layer=vector_features_path,\n", |
2345 |
| - " base_output_filename=s2_product_id,\n", |
2346 |
| - " output_dir=download_directory / \"test_sentinel2_clip\")" |
| 2346 | + "clip_list = clip_raster_with_polygon(\n", |
| 2347 | + " raster_image=product_path,\n", |
| 2348 | + " polygon_layer=vector_features_path,\n", |
| 2349 | + " base_output_filename=s2_product_id,\n", |
| 2350 | + " output_dir=download_directory / \"test_sentinel2_clip\",\n", |
| 2351 | + ")" |
2347 | 2352 | ]
|
2348 | 2353 | },
|
2349 | 2354 | {
|
|
0 commit comments