[gdal-dev] Setting the georeferencing priority for GDAL

Even Rouault even.rouault at mines-paris.org
Mon Oct 28 14:26:31 PDT 2013


Hi Jukka,

> 
> Sometimes an image can have several and ambiguous metadata for
> georeferencing. Mapserver has a method to deal with ambiguous internal
> geotiff metadata and world files and user can override the internal
> metadata by using PROCESSING "EXTENT_PRIORITY=WORLD" in the mapfile.
> http://www.mapserver.org/input/raster.html#special-processing-directives.
> I thought it was PROCESSING "EXTENT_PRIORITY=WORLDFILE" but perhaps both
> keywords are supported.
> 
> I wonder if GDAL supports this same worldfile override with some secret
> config option. At least it is not listed on page
> http://trac.osgeo.org/gdal/wiki/ConfigOptions.
> 
> I can also see that GDAL does have a config option GMLJP2OVERRIDE but I
> could not easily find what is is doing.

/* -------------------------------------------------------------------- */
/*      This is a backdoor to let us embed a literal gmljp2 chunk       */
/*      supplied by the user as an external file.  This is mostly       */
/*      for preparing test files with exotic contents.                  */
/* -------------------------------------------------------------------- */

> 
> And finally when I was playing with a "gdal_edit.py" utility I discovered
> that there are at least 4 ways to georeference a JPEG2000 file:
> - use worldfile .wld or .j2w
> - use internal GeoJP2 (GeoTIFF) georeferencing
> - use internal GML georeferencing
> - use an external .aux.xlm file
> 
> I noticed that command
>  python gdal_edit.py -a_srs epsg:3067 metajp2test.jp2
> was creating a file names "metajp2test.jp2.aux" which does contain the
> right georeferencing data.

> However, if I run gdalinfo it is looking for
> the internal GeoJP2 metadata and it reports that my JPEG2000 file is still
> using an unknown projection.

Was it with the JP2OPENJPEG driver ? JP2KAK and JP2ECW should return what is 
found in .aux.xml.

I also agree with Frank that PAM information should override internal 
information.

In the case of JPEG2000, I think it might be possible, pending some work, to 
edit the JP2 boxes to rewrite the GeoJP2 and/or GMLJP2 boxes in place. Well, 
maybe not in all cases if the size of the new boxes is larger than the old 
boxes. In which case a utility could rewrite a slightly larger file by shifting 
the compressed imagery off a few bytes, but without modifying it at all.

> 
> This feels a bit messy. Perhaps there is a need to have a GDAL wide config
> option for what metadata to search and use for georeferencing. In my case I
> would like to set it to use "external GDAL aux.xml". In addition, I think
> that this setting should be made safe so that if aux.xml file is not found
> then the image is considered to be without georeferencing. Or perhaps the
> config option could take a list like "auxiliary_xml,GeoJP2" with all the
> acceptable alternatives in priority order.
> 

Even

-- 
Geospatial professional services
http://even.rouault.free.fr/services.html


More information about the gdal-dev mailing list