[gdal-dev] Gdal + Kakadu + Python : unable to write JPEG2000 correctly

Even Rouault even.rouault at spatialys.com
Wed Feb 15 07:09:55 PST 2017

On mercredi 15 février 2017 07:04:06 CET CGA wrote:
> Dear all,
> I'm struggling with the Python bindings of GDAL + Kakadu. I'm trying to clip
> a small part of an input image in .jp2 and write it inside another .jp2
> file.
> I read that the JP2KAK images can only be created using the CreateCopy()
> method. Here is my workflow :
>   - Open input dataset
>   - Clip image using ReadAsArray (load into a numpy array)
>   - Create a new dataset (using MEM or GTiff driver)
>   - Write clipped array in new dataset
>   - Convert created dataset to JP2 using JP2KAK driver CreateCopy() method
> As a result, I get a JP2 image that contains only one value : 32768 ....
> When using the intermediate GTiff driver, I confirmed that the intermediate
> dataset is valid.
> Here is the code used :
> I also tried the following simple script that seems to be working fine (the
> script only CreateCopy of an existing JP2 dataset) :
> Is there anything wrong in the way I'm creating the JP2 clipped dataset in
> the first script ?

Does a simple gdal_translate in.jp2 out.jp2 -of JP2KAK work ? I believe there is (or was) 
signedness issues with 16 bit integers.

Spatialys - Geospatial professional services
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170215/58318616/attachment.html>

More information about the gdal-dev mailing list