satpy.writers.ninjogeotiff module

Writer for GeoTIFF images with tags for the NinJo visualization tool.

The next version of NinJo (release expected spring 2022) will be able to read standard GeoTIFF images, with required metadata encoded as a set of XML tags in the GDALMetadata TIFF tag. Each of the XML tags must be prepended with 'NINJO_'. For NinJo delivery, these GeoTIFF files supersede the old NinJoTIFF format. The NinJoGeoTIFFWriter therefore supersedes the old Satpy NinJoTIFF writer and the pyninjotiff package.

The reference documentation for valid NinJo tags and their meaning is contained in NinJoPedia. Since this page is not in the public web, there is a (possibly outdated) mirror.

There are some user-facing differences between the old NinJoTIFF writer and the new NinJoGeoTIFF writer. Most notably, keyword arguments that correspond to tags directly passed by the user are now identical, including case, to how they will be written to the GDALMetaData and interpreted by NinJo. That means some keyword arguments have changed, such as summarised in this table:

Migrating to NinJoGeoTIFF, keyword arguments for the writer

ninjotiff (old)

ninjogeotiff (new)




















Moreover, two keyword arguments are no longer supported because their functionality has become redundant. This applies to ch_min_measurement_unit and ch_max_measurement_unit. Instead, pass those values in source units to the stretch() enhancement with the min_stretch and max_stretch arguments.

class satpy.writers.ninjogeotiff.NinJoGeoTIFFWriter(dtype=None, tags=None, **kwargs)[source]

Bases: satpy.writers.geotiff.GeoTIFFWriter

Writer for GeoTIFFs with NinJo tags.

This writer is experimental. API may be subject to change.

For information, see module docstring and documentation for save_image().

Init the writer.

save_image(image, filename=None, fill_value=None, compute=True, keep_palette=False, cmap=None, overviews=None, overviews_minsize=256, overviews_resampling=None, tags=None, config_files=None, *, ChannelID, DataType, PhysicUnit, PhysicValue, SatelliteNameID, **kwargs)[source]

Save image along with NinJo tags.

Save image along with NinJo tags. Interface as for GeoTIFF, except NinJo expects some additional tags. Those tags will be prepended with ninjo_ and added as GDALMetaData.

Writing such images requires trollimage 1.16 or newer.

Importing such images with NinJo requires NinJo 7 or newer.

  • image (XRImage) – Image to save.

  • filename (str) – Where to save the file.

  • fill_value (int) – Which pixel value is fill value?

  • compute (bool) – To compute or not to compute, that is the question.

  • keep_palette (bool) – As for parent GeoTIFF save_image().

  • cmap (trollimage.colormap.Colormap) – As for parent save_image().

  • overviews (list) – As for save_image().

  • overviews_minsize (int) – As for save_image().

  • overviews_resampling (str) – As for save_image().

  • tags (dict) – Extra (not NinJo) tags to add to GDAL MetaData

  • config_files (Any) – Not directly used by this writer, supported for compatibility with other writers.

Remaining keyword arguments are either passed as GDAL options, if contained in self.GDAL_OPTIONS, or they are passed to NinJoTagGenerator, which will include them as NinJo tags in GDALMetadata. Supported tags are defined in NinJoTagGenerator.optional_tags. The meaning of those (and other) tags are defined in the NinJo documentation (see module documentation for a link to NinJoPedia). The following tags are mandatory and must be provided as keyword arguments:

ChannelID (int)

NinJo Channel ID

DataType (int)

NinJo Data Type

SatelliteNameID (int)

NinJo Satellite ID

PhysicUnit (str)

NinJo label for unit (example: “C”)

PhysicValue (str)

NinJo label for quantity (example: “temperature”)

class satpy.writers.ninjogeotiff.NinJoTagGenerator(image, fill_value, filename, **kwargs)[source]

Bases: object

Class to collect NinJo tags.

This class is used by NinJoGeoTIFFWriter to collect NinJo tags. Most end-users will not need to create instances of this class directly.

Tags are gathered from three sources:

  • Fixed tags, contained in the attribute fixed_tags. The value of those tags is hardcoded and never changes.

  • Tags passed by the user, contained in the attribute passed_tags. Those tags must be passed by the user as arguments to the writer, which will pass them on when instantiating this class.

  • Tags calculated from data and metadata. Those tags are defined in the attribute dynamic_tags. They are either calculated from image data, from image metadata, or from arguments passed by the user to the writer.

Some tags are mandatory (defined in mandatory_tags). All tags that are not mandatory are optional. By default, optional tags are generated if and only if the required information is available.

Initialise tag generator.

  • image (trollimage.xrimage.XRImage) – XRImage for which NinJo tags should be calculated.

  • fill_value (int) – Fill value corresponding to image.

  • filename (str) – Filename to be written.

  • **kwargs – Any additional tags to be included as-is.

dynamic_tags = {'CentralMeridian': 'central_meridian', 'ColorDepth': 'color_depth', 'CreationDateID': 'creation_date_id', 'DateID': 'date_id', 'EarthRadiusLarge': 'earth_radius_large', 'EarthRadiusSmall': 'earth_radius_small', 'FileName': 'filename', 'MaxGrayValue': 'max_gray_value', 'MinGrayValue': 'min_gray_value', 'Projection': 'projection', 'ReferenceLatitude1': 'ref_lat_1', 'TransparentPixel': 'transparent_pixel', 'XMaximum': 'xmaximum', 'YMaximum': 'ymaximum'}
fixed_tags = {'HeaderVersion': 2, 'Magic': 'NINJO', 'XMinimum': 1, 'YMinimum': 1}

Get a dictionary with all tags for NinJo.


Calculate central meridian.


Return the color depth.


Calculate the creation date ID.

That’s seconds since UNIX Epoch for the time the image is created.


Calculate the date ID.

That’s seconds since UNIX Epoch for the time corresponding to the satellite image start of measurement time.


Return the Earth semi-major axis in metre.


Return the Earth semi-minor axis in metre.


Return the filename.


Calculate maximum gray value.


Get the easternmost longitude of the area.

Currently not implemented. In pyninjotiff it was implemented but the answer was incorrect.


Get the westernmost longitude of the area.

Currently not implemented. In pyninjotiff it was implemented but the answer was incorrect.


Calculate minimum gray value.


Get NinJo projection string.

From the documentation, valid values are:

  • NPOL/SPOL: polar-sterographic North/South

  • PLAT: „Plate Carrée“, equirectangular projection

  • MERC: Mercator projection

Derived from AreaDefinition.


Get reference latitude one.

Derived from area definition.


Get reference latitude two.

This is not implemented and never was correctly implemented in pyninjotiff either. It doesn’t appear to be used by NinJo.


Get value for NinJo tag.


Get the transparent pixel value, also known as the fill value.


Get the maximum value of x, i.e. the meridional extent of the image in pixels.


Get the maximum value of y, i.e. the zonal extent of the image in pixels.

mandatory_tags = {'AxisIntercept', 'ChannelID', 'ColorDepth', 'CreationDateID', 'DataType', 'DateID', 'Gradient', 'HeaderVersion', 'MaxGrayValue', 'MinGrayValue', 'PhysicUnit', 'PhysicValue', 'Projection', 'SatelliteNameID', 'SatelliteNumber', 'TransparentPixel', 'XMaximum', 'XMinimum', 'YMaximum', 'YMinimum'}
optional_tags = {'AOSAzimuth', 'Altitude', 'CentralMeridian', 'ColorTable', 'DataSource', 'Description', 'EarthRadiusLarge', 'EarthRadiusSmall', 'GeoLatitude', 'GeoLongitude', 'GeodeticDate', 'IsAtmosphereCorrected', 'IsBlackLinesCorrection', 'IsCalibrated', 'IsNormalized', 'IsValueTableAvailable', 'LOSAzimuth', 'MaxElevation', 'MeridianEast', 'MeridianWest', 'OriginalHeader', 'OverFlightTime', 'OverflightDirection', 'ReferenceLatitude1', 'ReferenceLatitude2', 'ValueTableFloatField'}
passed_tags = {'ChannelID', 'DataType', 'PhysicUnit', 'PhysicValue', 'SatelliteNameID'}
postponed_tags = {'AxisIntercept', 'Gradient'}