Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# 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
# sphinx_gallery_thumbnail_number = 5
fig, ax = plt.subplots(figsize=(12, 6))
crop_bound_utm13N.boundary.plot(ax=ax, color="red", zorder=10)
ep.plot_rgb(
cropped_array,
ax=ax,
stretch=True,
extent=crop_extent,
title="Cropped Raster and Fire Boundary",