Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
crop_raster_profile = raster_crs.profile
crop_bound_utm13N = crop_bound.to_crs(crop_raster_profile["crs"])
#############################################################################
# Crop Each Band
# --------------
# When you need to crop and stack a set of images, it is most efficient to first
# crop each image, and then stack it.
# `es.crop_all()` is an efficient way to crop all bands in an image quickly.
# The function will write out cropped rasters to a
# directory and return a list of file paths that can then be used with
# `es.stack()`.
os.chdir(os.path.join(et.io.HOME, "earth-analytics"))
band_paths_list = es.crop_all(
stack_band_paths, output_dir, crop_bound_utm13N, overwrite=True
)
#############################################################################
# Stack All Bands
# ---------------
# Once the data are cropped, you are ready to create a new stack.
os.chdir(os.path.join(et.io.HOME, "earth-analytics"))
cropped_array, array_raster_profile = es.stack(band_paths_list, nodata=-9999)
crop_extent = plotting_extent(
cropped_array[0], array_raster_profile["transform"]
)
# Plotting the cropped image