Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NITF Pansharpening #529

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

NITF Pansharpening #529

wants to merge 6 commits into from

Conversation

BryonLewis
Copy link
Contributor

@BryonLewis BryonLewis commented Oct 30, 2024

  • Limits downloading to 'nitf:compressing' == 'NC' or non-compressed NITF files. C8 files are skipped
  • Classifies images as panchromatic (having instruments = ['panchromatic'] or visual (having instruments = ['multi-vis']). After getting the captures it will attempt to add panuri fields to any image that it can find that is panchromatic and within 60 seconds timestamp of the original visual image
  • The replacing of the 'microsecond' for the time is because some images in the STAC server report with microseconds and others don't. This unifies it so it is easier to find the same timestamp.
  • The Try/Except for the animation export was turned off (probably for testing or checking errors) so I turned it back on.

TODO:

  • Testing for what the system does if it finds a compression other than 'NC' or 'C8' (error out?)
  • Handle other instruments like ['swir-multi']
    • Going to ignore anything other than ['panchromatic'] or ['multi-vis']
  • Getting an error 'WarpedVRT does not permit boundless reads'
  • Error: 'bounds and transform are inconsistent'
    • Not entirely sure but this seems like an issue where the Metadata for a NITF doesn't match the NITF itself. If I force riotiler to ignore the error it creates an upside-down image.

NOTES:

  • The 'bounds and transform are inconsistent' and the 'WarpedVRT does not permit boundless reads' are both currently being caught and logged as 'info' in the system to allow for the downloading of a majority of images.

@BryonLewis BryonLewis marked this pull request as ready for review November 8, 2024 13:05

return rgb.render(img_format=format)
logger.info(f'Downloading WorldView NITF bbox: {bbox} scale: {scale}')
if capture.panuri is not None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A refactoring nit: based on my read-through, this looks like a block of code for enhancing a vis_img with the pansharpened image, if the pansharpened image URI is available. This will reduce duplication in the event adjustments are needed down the line.

with Reader(input=capture.uri) as vis_img:
  pan_chip = None
  if capture.panuri is not None:
    with Reader(input=capture.panuri) as pan_img:
      pan_chip = ...
  
  ...

  size = {'width': pan_chip.width, 'height': pan_chip.height} if pan_chip else {}
  vis_chip = vis_img.part(..., **size)
  
  ...

  if pan_chip:
    final_chip = ImageData(vis_chip, pan_chip, ...)
  else:
    final_chip = vis_chip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants