Untitled

 avatar
unknown
plain_text
2 years ago
649 B
5
Indexable
import xarray as xr
import cartopy.crs as ccrs
import matplotlib.pyplot as plt

hdf_file = "/srv/ccrc/RegClim2/z3540003/Winter_School/MOD13Q1.A2023001.h31v11.006.2023018081419.hdf"

# Read the HDF file using xarray
data = xr.open_dataset(hdf_file)

# Extract the NDVI variable from the dataset
ndvi = data['250m 16 days NDVI']

# Create a plot using Cartopy
fig = plt.figure(figsize=(10, 8))
ax = plt.axes(projection=ccrs.PlateCarree())

# Plot the NDVI data
ndvi.plot(ax=ax, transform=ccrs.PlateCarree(), cmap='RdYlGn')

# Add map features
ax.coastlines()
ax.gridlines()

# Set plot title
plt.title('MODIS 16-Day NDVI')

# Show the plot
plt.show()
Editor is loading...