Region = sa_boundary.geometry().bounds(), # Or use custom ee.Geometry.Rectangle()įolder = "south_africa_viirs_dnb_nightlights_v1_vcmslcfg", # Export the image with the original CRS and geotransform # Create a filename for the downloaded image # Get the original CRS and geotransform of the image Image = maskOutside(image, sa_boundary).unmask(-9999) # Replace all values outside region with -9999 Image = ee.Image(image_id).select('avg_rad') Mask = ee.nstant(1).clip(geometry).mask() # add. # Function to mask all values outside the geometry Sa_boundary = ee.FeatureCollection("FAO/GAUL/2015/level0").filter(ee.Filter.eq("ADM0_NAME", "South Africa")) Image_ids = viirs.aggregate_array("system:id").getInfo() # Get a list of all the image IDs (I'll use it to fetch images directly using ee.Image()) Full code for the South Africa Nightlights example: import ee So the way to go about it is to save a rectangular region around the geometry you want to export, and then set all values outside your geometry to a no-data value using a mask. But you cannot do that, the region argument of ee.() expects a rectangular boundary, created e.g. So the problem with the above code is that it tries to clip an image to a non-rectangular shape file and save that as GeoTIFF, which strangely enough executes, and generates multiple files. In particular: why are there different versions of the same image (the constructed names are all unique, as evident from the printout), and what are these numbers appended to the file name? This code runs perfectly, but in my drive I get something very odd: Sa = ee.FeatureCollection("FAO/GAUL/2015/level0").filter(ee.Filter.eq("ADM0_NAME", "South Africa"))įor i in range(viirs_list.size().getInfo()):ĭ = get_date(img) # Data is monthly, so this gets year and monthĭescription = 'Download South Africa Nightlights',įolder = "south_africa_viirs_dnb_nightlights",įileNamePrefix = 'south_africa_viirs_dnb_monthly_v1_vcmslcfg_' + d.replace('-', '_'), Viirs = ee.ImageCollection("NOAA/VIIRS/DNB/MONTHLY_V1/VCMSLCFG").select('avg_rad') I thought exporting images from GEE should be quite straightforward, turns out I am facing difficulties, and I'm not satisfied with the answers given so far on this platform.Īs a minimal example, I want to extract nightlights images at original scale for South Africa: import ee
0 Comments
Leave a Reply. |