Paste: satpy
Author: | 11 |
Mode: | python |
Date: | Sun, 12 Jun 2022 08:59:38 |
Plain Text |
import os
from glob import glob
from satpy.scene import Scene
import datetime
import matplotlib.pyplot as plt
import cartopy
import cartopy.crs as ccrs
from cartopy._crs import (CRS, Geodetic, Globe, PROJ4_VERSION,
WGS84_SEMIMAJOR_AXIS, WGS84_SEMIMINOR_AXIS)
filenames = glob('C:/Users/Administrator/Desktop/FY4B*')
from pyresample import create_area_def
crop_def = create_area_def('Singapore',
{'proj': 'longlat', 'datum': 'WGS84'},
area_extent=[103, 1, 104, 2 ],
resolution= 0.05,
shape=(800, 800),
units='degrees',
description='Global 1x1 degree lat-lon grid')
scn = Scene(filenames, reader='agri_l1')
composite = "true_color"
scn.load([composite])
area_def = scn['true_color'].attrs['area']
x_slice, y_slice = area_def.get_area_slices(crop_def)
target_area = area_def[y_slice, x_slice]
new_scn = scn.resample(target_area)
fig = plt.figure(figsize=(5,5))
ax=plt.axes(projection=CRS)
CRS= new_scn['true_color'].attrs['area'].to_cartopy_crs()
new_scn['true_color'].plot.imshow(rgb='bands', ax=ax, origin='upper', transform=CRS)
ax.coastlines(resolution='10m', color='white', linewidth=0.25)
ax.gridlines()
plt.title('Image of singapore', loc='left', fontweight='bold', fontsize=15)
New Annotation