Opened 12 years ago

Closed 12 years ago

#2546 closed defect (fixed)

SetProjection does not update Datum GeoTiff tags in a specific case

Reported by: vjetly Owned by: warmerdam
Priority: high Milestone: 1.5.3
Component: GDAL_Raster Version: 1.5.2
Severity: normal Keywords: GTiff libgeotiff setprojection


In place update of projection using SetProjection?() fails to update Datum tags when trying to set the projection to any UTM zone with NAD83 datum in the attached image.

The image already has some 'LOCAL_CS' projection tags. When these tags are not present updating the projection works fine. Also setting the projection to geographic NAD83 works fine but not to UTM NAD83.

Attachments (1)

greene_sub.tif (252.8 KB) - added by vjetly 12 years ago.
GeoTIFF on which SetProjection?() works partially

Download all attachments as: .zip

Change History (5)

Changed 12 years ago by vjetly

Attachment: greene_sub.tif added

GeoTIFF on which SetProjection?() works partially

comment:1 Changed 12 years ago by warmerdam

Status: newassigned

I have confirmed, testing with this script:

!/usr/bin/env python

import os
import sys
import ogr
import gdal
import gdalnumeric
import osr

os.system('cp safe.tif greene_sub.tif')

db = gdal.Open('greene_sub.tif',gdal.GA_Update)

srs = osr.SpatialReference()
print srs.ExportToPrettyWkt()

db = None

The problem is that the input file has an explicit GCS item in the geotiff info:

      GTModelTypeGeoKey (Short,1): User-Defined
      GTRasterTypeGeoKey (Short,1): RasterPixelIsArea
      GTCitationGeoKey (Ascii,17): "METRE           "
      GeographicTypeGeoKey (Short,1): GCS_WGS_84
      GeogAngularUnitsGeoKey (Short,1): Angular_Degree
      ProjLinearUnitsGeoKey (Short,1): Linear_Meter

But the updated geotiff info does not wipe away unnecessary elements, though it does overwrite those it wishes to update.

      GTModelTypeGeoKey (Short,1): ModelTypeProjected
      GTRasterTypeGeoKey (Short,1): RasterPixelIsArea
      GTCitationGeoKey (Ascii,26): "NAD83 / Idaho East (ftUS)"
      GeographicTypeGeoKey (Short,1): GCS_WGS_84
      GeogCitationGeoKey (Ascii,6): "NAD83"
      GeogAngularUnitsGeoKey (Short,1): Angular_Degree
      ProjectedCSTypeGeoKey (Short,1): Unknown-2241
      ProjLinearUnitsGeoKey (Short,1): Linear_Foot_US_Survey

The solution, I imagine, is to add some way of actually clearing an existing geotiff info structure rather than just attempting to update it in place.

comment:2 Changed 12 years ago by warmerdam

Component: PythonBindingsGDAL_Raster
Keywords: GTiff libgeotiff added; python removed

comment:3 Changed 12 years ago by warmerdam

Milestone: 1.5.3

Unfortunately libgeotiff does not provide a mechanism to create an empty GTIF structure related to a file with existing geotiff info. Also, libtiff does not provide a mechanism to clear an existing tag in a GeoTIFF file.

So, I've taken the approach of reducing the geotiff tags to a minimum set when updating the file (r15293 in trunk). I have also written a test suite entry to verify this correction (r15292).

comment:4 Changed 12 years ago by warmerdam

Resolution: fixed
Status: assignedclosed

I have migrated the change into the 1.5 branch (r15294).

I believe this problem is now resolved.

Note: See TracTickets for help on using tickets.