79258929

Date: 2024-12-06 18:03:30
Score: 0.5
Natty:
Report link

Set values you dont want to show to np.nan:

import rasterio
from matplotlib import pyplot as plt
slope_raster = r"C:\gistest\minislope.tif"
import numpy as np

fig, (ax1, ax2) = plt.subplots(nrows=1, ncols=2, figsize=(10,20))

src = rasterio.open(slope_raster)
arr = src.read(1)
ax1.set_title("Original slope raster")
ax1.imshow(arr)

ax2.set_title("Slopes greater than 20 % masked")
arr2 = arr.copy()
arr2[arr2>20] = np.nan
ax2.imshow(arr2)

enter image description here

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
Posted by: Bera