Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
arr_st, meta = es.stack(landsat_paths_pre)
# Import the landsat qa layer
with rio.open(
"data/cold-springs-fire/landsat_collect/LC080340322016070701T1-SC20180214145604/crop/LC08_L1TP_034032_20160707_20170221_01_T1_pixel_qa_crop.tif"
) as landsat_pre_cl:
landsat_qa = landsat_pre_cl.read(1)
landsat_ext = plotting_extent(landsat_pre_cl)
###############################################################################
# Plot Histogram of Each Band in Your Data
# ----------------------------------------
# You can view a histogram for each band in your dataset by using the
# ``hist()`` function from the ``earthpy.plot`` module.
ep.hist(arr_st)
plt.show()
###############################################################################
# Customize Histogram Plot with Titles and Colors
# -----------------------------------------------
ep.hist(
arr_st,
colors=["blue"],
title=[
"Band 1",
"Band 2",
"Band 3",
"Band 4",
"Band 5",
"Band 6",
# sphinx_gallery_thumbnail_number = 1
ep.hist(array_stack, colors=colors_list, title=titles)
plt.show()
###############################################################################
# Customize Bin Size and Arrangement of Histograms
# -------------------------------------------------
#
# You can customize the number of bins each histogram plot uses to group the
# data it is plotting. The default number is 20. This can be adjusted to match
# the data you are trying to display. Additionally, you can change the
# arrangement of the image overall by modifying the number of columns used
# to plot the data.
# Plot each histogram with 50 bins, arranged across three columns
ep.hist(array_stack, bins=50, cols=3)
plt.show()
"midnightblue",
"Blue",
"Green",
"Red",
"Maroon",
"Purple",
"Violet",
]
# Create the list of titles for each band. The titles and colors listed
# in this example reflect the order and wavelengths of the Landsat 8 bands
titles = ["Ultra Blue", "Blue", "Green", "Red", "NIR", "SWIR 1", "SWIR 2"]
# Plot the histograms with the color and title lists you just created
# sphinx_gallery_thumbnail_number = 1
ep.hist(array_stack, colors=colors_list, title=titles)
plt.show()
###############################################################################
# Customize Bin Size and Arrangement of Histograms
# -------------------------------------------------
#
# You can customize the number of bins each histogram plot uses to group the
# data it is plotting. The default number is 20. This can be adjusted to match
# the data you are trying to display. Additionally, you can change the
# arrangement of the image overall by modifying the number of columns used
# to plot the data.
# Plot each histogram with 50 bins, arranged across three columns
ep.hist(array_stack, bins=50, cols=3)
plt.show()
ep.hist(array, title=["Band 1", "Band 2", "Band 3"])
plt.show()
###########################################################################
# No Data Option
# ---------------
# ``es.stack()`` can handle ``nodata`` values in a raster. To use this
# parameter, specify ``nodata=``. This will mask every pixel that contains
# the specified ``nodata`` value. The output will be a numpy masked array.
os.chdir(os.path.join(et.io.HOME, "earth-analytics"))
array_nodata, raster_prof_nodata = es.stack(stack_band_paths, nodata=-9999)
# View hist of data with nodata values removed
ep.hist(
array_nodata,
title=[
"Band 1 - No Data Values Removed",
"Band 2 - No Data Values Removed",
"Band 3 - No Data Values Removed",
],
)
plt.show()
# Recreate extent object for the No Data array
extent_nodata = plotting_extent(
array_nodata[0], raster_prof_nodata["transform"]
)
################################################################################
stretch=True,
extent=extent,
str_clip=0.5,
title="RGB Image of Un-cropped Raster",
)
plt.show()
################################################################################
# Explore the Range of Values in the Data
# ---------------------------------------
# You can explore the range of values found in the data using the EarthPy ``hist()``
# function. Do you notice any extreme values that may be impacting the stretch
# of the image?
ep.hist(array, title=["Band 1", "Band 2", "Band 3"])
plt.show()
###########################################################################
# No Data Option
# ---------------
# ``es.stack()`` can handle ``nodata`` values in a raster. To use this
# parameter, specify ``nodata=``. This will mask every pixel that contains
# the specified ``nodata`` value. The output will be a numpy masked array.
os.chdir(os.path.join(et.io.HOME, "earth-analytics"))
array_nodata, raster_prof_nodata = es.stack(stack_band_paths, nodata=-9999)
# View hist of data with nodata values removed
ep.hist(
array_nodata,
title=[
landsat_ext = plotting_extent(landsat_pre_cl)
###############################################################################
# Plot Histogram of Each Band in Your Data
# ----------------------------------------
# You can view a histogram for each band in your dataset by using the
# ``hist()`` function from the ``earthpy.plot`` module.
ep.hist(arr_st)
plt.show()
###############################################################################
# Customize Histogram Plot with Titles and Colors
# -----------------------------------------------
ep.hist(
arr_st,
colors=["blue"],
title=[
"Band 1",
"Band 2",
"Band 3",
"Band 4",
"Band 5",
"Band 6",
"Band 7",
],
)
plt.show()
###############################################################################
# View Single Band Plots