Visualizations routine

The software presents several ways of visualizing NOAA images:

  • as simple decoded image

  • as georeferenced raster

  • as an interactive web map with world map in the background

  • plotted on virtual globe

The visualization process is as follows:

  1. Decode the signal using one of the directdemod decoders.

  2. Preprocess the image using preprocess function from directdemod.georeferencer package.

  3. Georeference the image (see docs on georeferencer).

  4. Generate map and globe visualizations using CLI interface, it will create tiles and then generate map.html and globe.html files. You can open the map directly in browser. To view the virtual globe you have to start a server python -m http.server 8000 (python3), then go to https://localhost:8000/globe.html.

In the section below, are presented classes that are related to visualization of satellite imagery, along with some helper classes, which provide IO operations.

Image merger

Merger provides functionality, along with CLI interface, for merging several raster images. Merger supports several methods for overlapping parts of the images: average, max, first, last.

python -o o.tif -r average --files a.tif b.tif

Console options:

-f, --files

list of files to merge

-o, --output

name of output file

-r, --resample

name of resample algorithm

This module provides an API for merging multiple images. It extracts needed information and projects images onto mercator projection.

directdemod.merger.add_pixel_fn(filename: str, resample_name: str) → None[source]

inserts pixel-function into vrt file named ‘filename’

  • filename (string) – name of file, into which the function will be inserted

  • resample_name (string) – name of resampling method

directdemod.merger.build_vrt(vrt: str, files: List[str], resample_name: str) → None[source]

builds .vrt file which will hold information needed for overlay

  • vrt (string) – name of vrt file, which will be created

  • files (list) – list of file names for merging

  • resample_name (string) – name of resampling method

directdemod.merger.get_resample(name: str) → str[source]

retrieves code for resampling method


name (string) – name of resampling method


code of resample method

Return type

method string

directdemod.merger.main() → None[source]

CLI interface for satellite image merger

directdemod.merger.merge(files: List[str], output_file: str, resample: str = 'average') → None[source]

merges list of files using specific resample method for overlapping parts

  • files (list[string]) – list of files to merge

  • output_file (string) – name of output file

  • resample (string) – name of resampling method


This class provides an API for image georeferencing. Sample command to run, first generate tif raster with metadata, then georeference it using interface. The first command will extract the capture date from the name of wav file, and then will compute the coordinates of the satellite based on this date. Computed data will be stored in new file in ‘.tif’ format. This file could be then used for georeferencing.

python -f ../samples/SDRSharp_20190521_170204Z_137500000Hz_IQ.wav -i ../samples/decoded/SDRSharp_20190521_170204Z_137500000Hz.png

python -m -i ../samples/decoded/SDRSharp_20190521_170204Z_137500000Hz.tif

Console options:

-m, --map

flag to create map overlay

-i, --image

path to image file

class directdemod.georeferencer.Georeferencer(tle_file: str = '')[source]

This class provides an API for image georeferencing. It extracts the information from descriptor file, translates and warps the image to defined projection.

__init__(tle_file: str = '')[source]

Georeferencer constructor


tle_file (string, optional) – file with orbit parameters

static compute_angle(long1: float, lat1: float, long2: float, lat2: float) → float[source]

compute angle between 2 points, defined by latitude and longitude

  • long1 (float) – longitude of start point

  • lat1 (float) – latitude of start point

  • long2 (float) – longitude of end point

  • lat2 (float) – latitude of end point


angle between points

Return type


static compute_gcp(long: float, lat: float, angle: float, distance: float, width: float, height: float) → osgeo.gdal.GCP[source]

compute coordinate of GCP, using longitude and latitude of starting point, azimuth angle and distance to the point

  • long (float) – longitude of start point

  • lat (float) – latitude of start point

  • angle (float) – azimuth between start point and GCP

  • ( (distance) – obj: float): distance to point in meters

  • width (float) – w-axis coordinate

  • height (float) – height-axis coordinate


instance of GCP object

Return type


compute_gcps(descriptor: dict, image: numpy.ndarray) → List[osgeo.gdal.GCP][source]

compute set of Ground Control Points

  • descriptor (dict) – descriptor dictionary, which describes the image

  • image (np.ndarray) – image as np.ndarray


list of GCPs

Return type


static create_desc(descriptor: dict, output_file: str) → None[source]

create descriptor for output_file file

  • descriptor (dict) – descriptor dictionary

  • output_file (string) – name of the output file

georef(descriptor: dict, output_file: str, resample_alg=0) → None[source]

georeferences the satellite image from descriptor file using GDAL Python API

  • descriptor (dict) – descriptor dictionary

  • output_file (string) – name of the output file

  • resample_alg (gdalconst, optional) – algorithm for resampling

georef_os(descriptor: dict, output_file: str) → None[source]

georeferences the satellite image from descriptor file, using GDAL compiled binaries. Can be used when gdal binaries are available only

  • descriptor (dict) – descriptor dictionary

  • output_file (string) – name of the output file

georef_tif(image_name: str, output_file: str, resample_alg=0) → None[source]

georeferences the satellite image from tif file using GDAL Python API. Descriptor is extracted directly from tif file

  • image_name (string) – path to tiff file, which contains needed metadata

  • output_file (string) – path to output file

  • resample_alg (gdalconst) – resampling algorithm (nearest, bilinear, cubic)

static to_string_gcps(gcps: List[osgeo.gdal.GCP]) → str[source]

create string representation of gcp points


gcps (list) – list of gcp points


gcp points represented as a string

Return type


Map generation

To generate visualization of raster use interface. The following command will generate a TMS (Tile Map Service) and 2 visualization files in samples/tms directory.

python --raster ../samples/decoded/raster.tif --tms ../samples/tms

You can run map.html by opening in the browser.

To use globe.html go to tms directory and type the following command to start http server on port 8000 (for python3):

python -m http.server 8000

Then open browser and go to http://localhost:8000/globe.html.

Json encoder

Json encoder, which handles encoding numpy array and datetime objects.

class directdemod.misc.Encoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

JSON encoder, which handles np.ndarray and datetime objects

__init__(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

Constructor for JSONEncoder, with sensible defaults.

If skipkeys is false, then it is a TypeError to attempt encoding of keys that are not str, int, float or None. If skipkeys is True, such items are simply skipped.

If ensure_ascii is true, the output is guaranteed to be str objects with all incoming non-ASCII characters escaped. If ensure_ascii is false, the output can contain non-ASCII characters.

If check_circular is true, then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an OverflowError). Otherwise, no such check takes place.

If allow_nan is true, then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats.

If sort_keys is true, then the output of dictionaries will be sorted by key; this is useful for regression tests to ensure that JSON serializations can be compared on a day-to-day basis.

If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. None is the most compact representation.

If specified, separators should be an (item_separator, key_separator) tuple. The default is (‘, ‘, ‘: ‘) if indent is None and (‘,’, ‘: ‘) otherwise. To get the most compact JSON representation, you should specify (‘,’, ‘:’) to eliminate whitespace.

If specified, default is a function that gets called for objects that can’t otherwise be serialized. It should return a JSON encodable version of the object or raise a TypeError.

default(obj) → Any[source]

Encode the object


obj (object) – oject to encode


encoded object

Return type