[Gdal-dev] more problems

Frank Warmerdam warmerdam at pobox.com
Sat Nov 30 11:53:49 EST 2002


Vladimir Slepnev wrote:

> 	GDALAllRegister();
> 
> 	GDALDataset *output = (GDALDataset *) GDALOpen( "pic3.tiff", GA_Update );
> 	output->SetMetadataItem("TIFFTAG_DOCUMENTNAME","Sample data");
> 	printf("%s\n",output->GetMetadataItem("TIFFTAG_DOCUMENTNAME"));
> 
> 	delete output;
> 
> 	output = (GDALDataset *) GDALOpen( "pic3.tiff", GA_ReadOnly );
> 	printf("%s\n",output->GetMetadataItem("TIFFTAG_DOCUMENTNAME")); //Same line
> as above!
> 
> 	return 0;
> 
> Here is the output:
> 
> Sample data
> (null)

Vladimir,

Generally speaking GeoTIFF files aren't very updatable, even if opened
in update mode.  I will look into the metadata issue to see if I can
improve things, but the dependable way of getting the metadata set in
a GeoTIFF file is by having it set in the dataset passed to the CreateCopy()
method for GeoTIFF.


> Here's what I get if I write the string ""+proj=utm +zone=11 +ellps=WGS84
> +units=us-ft":
> 
>    Keyed_Information:
>       GTModelTypeGeoKey (Short,1): ModelTypeProjected
>       GTRasterTypeGeoKey (Short,1): RasterPixelIsArea
>       ProjectedCSTypeGeoKey (Short,1): User-Defined
>       ProjectionGeoKey (Short,1): Proj_UTM_zone_11N
>       ProjLinearUnitsGeoKey (Short,1): Linear_Foot_US_Survey
>       End_Of_Keys.
>    End_Of_Geotiff.

ProjectedCSTypeGeoKey is user defined in this case, because my libraries
don't know of a PCS code for UTM 11 N with us feet as the units.  A PCS
is a full projected coordinate system including GCS (datum/pm), linear
units, and a projection transformation method (ProjectionGeoKey).  When it
doesn't know a corresponding EPSG PCS code, it must define each of the
components indpendently.

As usual, +ellps=WGS84 is not equivlent to +datum=WGS84, so we have
no GCS/datum definition at all.  Peraps it ought to write an ellipsoid
definition in this case.  I will look into that.

So, in general this worked properly.


> Here's what I get if I write the string ""+proj=utm +zone=11 +datum=WGS84
> +units=us-ft":
> 
>    Keyed_Information:
>       GTModelTypeGeoKey (Short,1): ModelTypeProjected
>       GTRasterTypeGeoKey (Short,1): RasterPixelIsArea
>       ProjectedCSTypeGeoKey (Short,1): Unknown-4326
>       ProjLinearUnitsGeoKey (Short,1): Linear_Foot_US_Survey
>       End_Of_Keys.
>    End_Of_Geotiff.

Yikes! Major breakage.  I fixed the problem here.  It now comes out:

    Keyed_Information:
       GTModelTypeGeoKey (Short,1): ModelTypeProjected
       GTRasterTypeGeoKey (Short,1): RasterPixelIsArea
       GeographicTypeGeoKey (Short,1): GCS_WGS_84
       ProjectedCSTypeGeoKey (Short,1): User-Defined
       ProjectionGeoKey (Short,1): Proj_UTM_zone_11N
       ProjLinearUnitsGeoKey (Short,1): Linear_Foot_US_Survey
       End_Of_Keys.
    End_Of_Geotiff.


> Once again, the questions are:
> Why is ProjectedCSTypeGeoKey "user-defined" in the second case? What does it
> mean? Isn't it wrong?
> What is ProjectionGeoKey in the second case? Doesn't GDAL confuse it with
> ProjectedCSTypeGeoKey in the first case?
> Why is the third case so utterly wrong?
> And once again, why is the GTCitationGeoKey not written?

Citations are not required for GeoTIFF.  Nevertheless, I agree they
are desirable, so I will look into adding them.

> All I did was convert the string to WKT through an OGRSpatialReference and
> then write it using SetProjection(). I did _not_ use gdal_translate.

Nevertheless, they are similar mechanisms.  I used gdal_translate to
demonstrate because it makes it easy for anyone to try without writing
and compiling a test program.

So, fixes for the serious bug have been committed.   As well I did some
work to attach authority values to the WKT when reading from GeoTIFF.  I
will write again soon once I have looked at some of the other problems.
Be wary about updating from CVS since I have dramatically changed the
way the EPSG support works and this affects GeoTIFF alot.

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent





More information about the Gdal-dev mailing list