[Gdal-dev] GDALWarp API: units aren't transfered to the transformed dataset

Frank Warmerdam warmerdam at pobox.com
Thu Apr 15 15:01:02 EDT 2004


Brian Marchand wrote:
> Hello,
> 
>  
> 
> I started using the GDAL warp API to re-project datasets. Certain 
> elevation grids such as SDTS files have elevation units in feet. This is 
> correctly captured by the GetUnitType method of the GDALRasterBand 
> class. However, after the transform the new GDALRasterBand objects do 
> not have units set. Unless I’m doing something wrong, the units should 
> be carried over or at least a SetUnitType method should be added. I’m 
> using the “MEM” driver as the destination dataset driver.

Brian,

You are correct, the logic for creating a new file in gdalwarp.cpp only
copies the color table over from the source. No effort is made to copy
metadata, or other auxilary information like the units type.  The
convenience function GDALCreateAndReprojectImage() does not even copy the
color table.

Furthermore, the "special" data items UnitType, Offset and Scale do not even
have set methods on the GDALRasterBand class, so you can't even copy them
yourself.

I have modified the MEM and VRT drivers to have custom set methods for these
items, and the CreateCopy() method on the VRT driver will now clone this
information from a source dataset and preserve it in the XML VRT file.

However, that doesn't really help you much.  I don't really have much advice
other than that you will likely need to keep track of this stuff yourself
by some means.   You can now manually copy UnitType to a MEM dataset if you
include memdataset.h if that helps.

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