[gdal-dev] unable to create jpeg200 files with self compiled gdal and openjpeg

Even Rouault even.rouault at spatialys.com
Tue Jul 12 01:33:44 PDT 2016


André,

> 
> This code works for geotiff, but not for jpeg2000. There I'm getting the
> error: ERROR 6: GDALDriver::Create() ... no create method implemented
> for this format.

You cannot directly use Create() for any of the JPEG2000 drivers as Create() 
assumes random writing capabilities which the JPEG2000 format doesn't offer. So 
the solution is to create a temporary dataset (for example with the MEM driver 
if it fits into RAM, or with an intermediate GeoTIFF otherwise) and then 
CreateCopy() it to JPEG2000

Something like:

tmp_ds = 
gdal.GetDriverByName('MEM').Create('',img.shape[0],img.shape[1],1,gdal.GDT_UInt16) 
# here I 
rb = tmp_ds.GetRasterBand(1)
rb.WriteArray(img)
dr.CreateCopy(fn, tmp_ds)
tmp_ds = None

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list