Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#5437 closed defect (fixed)

Origin and corner points incorrect for pixel is point GeoJP2 JPEG2000

Reported by: degrootc Owned by: warmerdam
Priority: normal Milestone: 1.11.0
Component: GDAL_Raster Version: 1.10.1
Severity: normal Keywords: GeoJP2 JPEG2000 corner point
Cc:

Description (last modified by degrootc)

When parsing a pixel is point GeoJP2 referenced JPEG2000, GDAL does not correctly adjust for point based referencing. This was discovered when using the Kakadu demo to convert point referenced GeoTIFF data to JPEG2000 files. When using gdalinfo the origin and corner points are off by half of the resolution of a pixel because they have not been adjusted.

The correct adjustment logic for points is shown in the geotiff.ccp source file lines 6553-6557

if( bPixelIsPoint && !bPointGeoIgnore )
{
    adfGeoTransform[0] -= (adfGeoTransform[1] * 0.5 + adfGeoTransform[2] * 0.5);
    adfGeoTransform[3] -= (adfGeoTransform[4] * 0.5 + adfGeoTransform[5] * 0.5);
}

The gt_kwt_srs.cpp function GTIFWktFromMemBuf is used to parse the GeoTIFF box and calculate the origin for JPEG2000 files. The code listed above is missing from this function, therefore it does not correctly adjust the origin, and by extension the corner points.

I attached a patch file which should resolve this issue.

Attachments (2)

gt_wkt_srs.cpp.patch (1.7 KB ) - added by degrootc 10 years ago.
Patch file to add pixel is point check
gt_wkt_srs.cpp.diff (910 bytes ) - added by degrootc 10 years ago.
Diff file showing changes to add pixel is point check

Download all attachments as: .zip

Change History (5)

by degrootc, 10 years ago

Attachment: gt_wkt_srs.cpp.patch added

Patch file to add pixel is point check

by degrootc, 10 years ago

Attachment: gt_wkt_srs.cpp.diff added

Diff file showing changes to add pixel is point check

comment:1 by degrootc, 10 years ago

Description: modified (diff)

comment:2 by Even Rouault, 10 years ago

Component: defaultGDAL_Raster
Milestone: 1.11.0
Resolution: fixed
Status: newclosed

trunk r27181 "JPEG2000 drivers: take into account PixelIsPoint in GeoJP2 boxes to do the translation from GeoTIFF model to GDAL model (unless GTIFF_POINT_GEO_IGNORE is set to YES), consistently with GTiff driver, and expose AREA_OR_POINT=Point (based on patch by degrootc, #5437)"

comment:3 by Even Rouault, 10 years ago

trunk r27182 "JP2KAK, JP2ECW, JP2OpenJPEG, JPEG2000 CreateCopy(): take into account AREA_OR_POINT=Point if present to write the GeoJP2 box with the appropriate translation from GDAL model to GeoTIFF model (#5437)"

Note: See TracTickets for help on using tickets.