The base NITF header object (sarpy.io.general.nitf_elements.base)

Base NITF Header functionality definition.

class sarpy.io.general.nitf_elements.base.Unstructured(data=None, **kwargs)

Bases: NITFElement

A possible NITF element pattern which is largely unparsed - just a bytes array of a given length

classmethod minimum_length()

The minimum size in bytes that takes to write this header element.

Return type:

int

classmethod from_bytes(value, start)
Parameters:
  • value (bytes|str) – the header string to scrape

  • start (int) – the beginning location in the string

get_bytes_length()

Get the length of the serialized bytes array

Return type:

int

to_bytes()

Write the object to a properly packed str.

Return type:

bytes

to_json()

Serialize element to a json representation. This is intended to allow a simple presentation of the element.

Return type:

dict

class sarpy.io.general.nitf_elements.base.TRE

Bases: BaseNITFElement

An abstract TRE class - this should not be instantiated directly.

property TAG

The TRE tag.

Type:

str

property DATA

The TRE data.

property EL

The TRE element length.

Type:

int

get_bytes_length()

Get the length of the serialized bytes array

Return type:

int

to_bytes()

Write the object to a properly packed str.

Return type:

bytes

classmethod minimum_length()

The minimum size in bytes that takes to write this header element.

Return type:

int

classmethod from_bytes(value, start)
Parameters:
  • value (bytes|str) – the header string to scrape

  • start (int) – the beginning location in the string

to_json()

Serialize element to a json representation. This is intended to allow a simple presentation of the element.

Return type:

dict

class sarpy.io.general.nitf_elements.base.UnknownTRE(TAG, data)

Bases: TRE

property TAG

The TRE tag.

Type:

str

property DATA: bytes

The TRE data.

property EL

The TRE element length.

Type:

int

get_bytes_length()

Get the length of the serialized bytes array

Return type:

int

to_bytes()

Write the object to a properly packed str.

Return type:

bytes

classmethod from_bytes(value, start)
Parameters:
  • value (bytes|str) – the header string to scrape

  • start (int) – the beginning location in the string

classmethod minimum_length()

The minimum size in bytes that takes to write this header element.

Return type:

int

to_json()

Serialize element to a json representation. This is intended to allow a simple presentation of the element.

Return type:

dict

class sarpy.io.general.nitf_elements.base.TREList(tres=None, **kwargs)

Bases: NITFElement

A list of TREs. This is meant to be used indirectly through one of the header type objects, which controls the parsing appropriately.

to_json()

Serialize element to a json representation. This is intended to allow a simple presentation of the element.

Return type:

dict

classmethod from_bytes(value, start)
Parameters:
  • value (bytes|str) – the header string to scrape

  • start (int) – the beginning location in the string

get_bytes_length()

Get the length of the serialized bytes array

Return type:

int

classmethod minimum_length()

The minimum size in bytes that takes to write this header element.

Return type:

int

to_bytes()

Write the object to a properly packed str.

Return type:

bytes

class sarpy.io.general.nitf_elements.base.TREHeader(data=None, **kwargs)

Bases: Unstructured

classmethod from_bytes(value, start)
Parameters:
  • value (bytes|str) – the header string to scrape

  • start (int) – the beginning location in the string

get_bytes_length()

Get the length of the serialized bytes array

Return type:

int

classmethod minimum_length()

The minimum size in bytes that takes to write this header element.

Return type:

int

to_bytes()

Write the object to a properly packed str.

Return type:

bytes

to_json()

Serialize element to a json representation. This is intended to allow a simple presentation of the element.

Return type:

dict

class sarpy.io.general.nitf_elements.base.UserHeaderType(OFL=None, data=None, **kwargs)

Bases: Unstructured

classmethod from_bytes(value, start)
Parameters:
  • value (bytes|str) – the header string to scrape

  • start (int) – the beginning location in the string

get_bytes_length()

Get the length of the serialized bytes array

Return type:

int

to_bytes()

Write the object to a properly packed str.

Return type:

bytes

to_json()

Serialize element to a json representation. This is intended to allow a simple presentation of the element.

Return type:

dict

classmethod minimum_length()

The minimum size in bytes that takes to write this header element.

Return type:

int