[gdal-dev] Adding GMLJP2 metadata into existing JPEG2000 file

Rahkonen Jukka Jukka.Rahkonen at mmmtike.fi
Fri Apr 13 00:32:14 EDT 2012


Even Rouault wrote:

> Le mercredi 11 avril 2012 14:21:09, Jukka Rahkonen a écrit :
>> Hi,
>>
>> Do we have anything that could be used for injecting GMLJP2 georeferencing
>> metadata from a text file into an existing JPEG2000 image? I found a tool
>> called "JP2 Meta Editor" by a company j2k-codec which is usable for
>> individual images. However, only way to use it is through GUI and I have a
>> need to run a large batch. Hints about suitable tools for this task, free
>> or commercial, are welcome.

> Jukka,

> Your question made me look more closely at the capabilities of the JP2Box
> support in GDAL, and I discovered that I had to write just a few lines of code
> to add support for writing georeferencing in the existing openjpeg driver. See
> http://trac.osgeo.org/gdal/changeset/24220#file2 . Basically you just need to
> write the boxes at the end of the existing file.

> So adding georeferencing to a new file should be easily done by a small
> standalone utility using GDAL, not necessarily requiring to have support for
> JPEG2000 itself, or adding an implementation of SetGeoTransform() /
> SetProjection() methods in one of the existing JPEG2000 drivers.

> As far as updating an existing georeferencing is concerned, this might be more
> complex because it might require invalidating the existing GMLJP2 or GeoJP2
> boxes.

Hi,

Alex Sevaliev from j2k-codec.com already wrote such a tool for us. It can be used
in a fast mode when new GML boxes are written at the end of the JPEG2000 file
and then it is super fast even with however big files. In a normal mode it is checking 
if there is a GML box already. If yes, then it is replecing it, if not, then it adds the
boxes. Because of possible box replace the app always rewrites the whole JPEG2000
so it is slower. Then it is also placing the GML box before the image codestream 
because I thought that one JPEG2000 application I use was not able to read the boxes 
which were placed after the codestream. It is absolutely OK according to JPEG2000 
standard and I now believe that there was something else wrong with my test and
that application did not really had troubles with the boxes at the end of file.

GML metadata standard allows to insert several GML boxes into JPEG2000 file
inside upper level ASOC boxes. I told Alex not even to try to handle such complicated
cases with the new tiny application.

Alex may publish the tool as freeware in a future but it would be nice to have same 
kind of GDAL tool. Our need came from Inspire rules which will demand to include 
GML metadata if orthophotos are in JPEG2000 format.

-Jukka Rahkonen-



More information about the gdal-dev mailing list