GDAL Warp produces a black image

422 Views Asked by At

I am calling GDAL warp using the python distribution on a NITF file and it simply outputs all zero values which creates an empty black image. The command I'm calling is

import osgeo.gdal as gdal

gdal.Warp("out.ntf", "inp.ntf")

I've tried using Translate as sort of a test to make sure GDAL as a whole is functioning and it seems to output properly. The image data is all correct and displays as expected. Any thoughts as to what could be going wrong?

1

There are 1 best solutions below

2
On

One thing that's important is to close the Dataset, depending a little on how you run it (script, repl, notebook etc).

This Python interface to the command-line utilities returns an opened Dataset, so you can explicitly close it with.

import osgeo.gdal as gdal

ds = gdal.Warp("out.ntf", "inp.ntf")
ds = None

That will cause for example anything in the GDAL-cache to be properly flushed to disk.