Created
May 5, 2025 21:28
-
-
Save AdrianoPereira/71993e303fac16e63da954dc1f556510 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ee | |
| ee.Initialize() | |
| # Peru information | |
| regions = ee.FeatureCollection("FAO/GAUL/2015/level1").filter( | |
| ee.Filter.eq("ADM0_NAME", "Peru") | |
| ) | |
| # Landcover product | |
| landcover = ee.Image("COPERNICUS/Landcover/100m/Proba-V-C3/Global/2019") | |
| classification = landcover.select("discrete_classification") | |
| # Maximum region (máx 195 for GAUL-1 Peru) | |
| count = regions.size().getInfo() | |
| # Iterar sem .getInfo() | |
| # This loop save each TIF region into Google Drive | |
| for i in range(count): | |
| region = ee.Feature(regions.toList(count).get(i)) | |
| name = ee.String(region.get("ADM1_NAME")) | |
| task = ee.batch.Export.image.toDrive( | |
| image=classification.clip(region.geometry()), | |
| description=f"export_{i}", | |
| folder="EarthEngine_Exports", | |
| fileNamePrefix=name.replace(" ", "_").getInfo(), | |
| scale=100, | |
| region=region.geometry(), | |
| maxPixels=1e13 | |
| ) | |
| task.start() | |
| print(f"Exporting: {name.getInfo()}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment