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
# load FY4A filenames
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.glob('C:/Users/Administrator/Desktop/FY3D*')
filenames = glob('C:/Users/Administrator/Desktop/FY4B*')
# create the scene object
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)
#new_scn.save_dataset(composite, filename='FY4B_truecolor_{dt}.png'.format(dt=scn.start_time.strftime('%Y%m%d%H%M')))
fig = plt.figure(figsize=(5,5))

ax=plt.axes(projection=CRS)

# Create axis with Geostationary projection
CRS= new_scn['true_color'].attrs['area'].to_cartopy_crs()

# Add the RGB image to the figure. The data is in the same projection as the
# axis we just created.
new_scn['true_color'].plot.imshow(rgb='bands', ax=ax, origin='upper', transform=CRS)

# Add Coastlines and States
ax.coastlines(resolution='10m', color='white', linewidth=0.25)
ax.gridlines()
plt.title('Image of singapore', loc='left', fontweight='bold', fontsize=15)

New Annotation

Summary:
Author:
Mode:
Body: