satpy.enhancements.overlays module
Helpers for adding overlays and decorations to images.
- satpy.enhancements.overlays._burn_overlay(img, image_metadata, area, cw_, overlays)[source]
Burn the overlay in the image array.
- satpy.enhancements.overlays._create_overlays_dict(color, width, grid, level_coast, level_borders)[source]
Fill in the overlays dict.
- satpy.enhancements.overlays.add_decorate(orig, fill_value=None, **decorate)[source]
Decorate an image with text and/or logos/images.
This call adds text/logos in order as given in the input to keep the alignment features available in pydecorate.
An example of the decorate config:
decorate = { 'decorate': [ {'logo': {'logo_path': <path to a logo>, 'height': 143, 'bg': 'white', 'bg_opacity': 255}}, {'text': {'txt': start_time_txt, 'align': {'top_bottom': 'bottom', 'left_right': 'right'}, 'font': <path to ttf font>, 'font_size': 22, 'height': 30, 'bg': 'black', 'bg_opacity': 255, 'line': 'white'}} ] }
Any numbers of text/logo in any order can be added to the decorate list, but the order of the list is kept as described above.
Note that a feature given in one element, eg. bg (which is the background color) will also apply on the next elements unless a new value is given.
align is a special keyword telling where in the image to start adding features, top_bottom is either top or bottom and left_right is either left or right.
- satpy.enhancements.overlays.add_logo(orig, dc, img, logo)[source]
Add logos or other images to an image using the pydecorate package.
All the features of pydecorate’s
add_logoare available. See documentation of Welcome to the Pydecorate documentation! for more info.
- satpy.enhancements.overlays.add_overlay(orig_img, area, coast_dir, color=None, width=None, resolution=None, level_coast=None, level_borders=None, fill_value=None, grid=None, overlays=None)[source]
Add coastline, political borders and grid(graticules) to image.
Uses
colorfor feature colors wherecoloris a 3-element tuple of integers between 0 and 255 representing (R, G, B).Warning
This function currently loses the data mask (alpha band).
resolutionis chosen automatically if None (default), otherwise it should be one of:‘f’
Full resolution
0.04 km
‘h’
High resolution
0.2 km
‘i’
Intermediate resolution
1.0 km
‘l’
Low resolution
5.0 km
‘c’
Crude resolution
25 km
gridis a dictionary with key values as documented in detail in pycoast- eg. overlay={‘grid’: {‘major_lonlat’: (10, 10),
‘write_text’: False, ‘outline’: (224, 224, 224), ‘width’: 0.5}}
Here major_lonlat is plotted every 10 deg for both longitude and latitude, no labels for the grid lines are plotted, the color used for the grid lines is light gray, and the width of the gratucules is 0.5 pixels.
For grid if aggdraw is used, font option is mandatory, if not
write_textis set to False:font = aggdraw.Font('black', '/usr/share/fonts/truetype/msttcorefonts/Arial.ttf', opacity=127, size=16)
- satpy.enhancements.overlays.add_scale(orig, dc, img, scale)[source]
Add scale to an image using the pydecorate package.
All the features of pydecorate’s
add_scaleare available. See documentation of Welcome to the Pydecorate documentation! for more info.
- satpy.enhancements.overlays.add_text(orig, dc, img, text)[source]
Add text to an image using the pydecorate package.
All the features of pydecorate’s
add_textare available. See documentation of Welcome to the Pydecorate documentation! for more info.