[Gdal-dev] Help with reprojection of a quicklook...

Frank Warmerdam warmerdam at pobox.com
Mon Aug 18 14:31:02 EDT 2003


Jeff Jacober wrote:
> Hello.
> 
> I have an 8 bit JPEG image that I am trying to reproject.
> 
> The image is a quicklook (basically a thumbnail) of a raw Spot scene.
> 
> I have control point data for the image which basically consists of 5 
> pixel locations and the corresponding Lat/Lon coords (the 4 corners and 
> the center pixel). This data is contained in a separate text file.
> 
> I see that this type of thing can be done using something like:
> 
> % gdalwarp -t_srs '+proj=utm +zone=11 +datum=WGS84' raw_spot.tif utm11.tif
> 
> however, this assumes the control point information is contained in the 
> source file.  In my case, I have a jpeg source file with no control 
> information contained therein.
> 
> Can anyone give me some advice on how I can accomplish this. Perhaps 
> convert my jpeg to a geoTiff first and somehow add the control point info?
> 
> Thanks in advance for any help.

Jeff,

I really meant to address this during the previous discussion of how to
associate GCPs with an image, but somehow never got to it.

My suggestion is to create a virtual file referring to your source file,
and add the GCPs in that virtual file.

This is an example of a simple VRT file that refers to a TIFF file (but
it could be a JPEG file too) and associates some GCPs with it:

<VRTDataset rasterXSize="380" rasterYSize="765">
   <GCPList>
     <GCP Id="1" Pixel="0.0000" Line="0.0000" X="9.233000000000E+01" Y="-9.522750000000E+01"/>
     <GCP Id="2" Pixel="380.0000" Line="0.0000" X="1.716000000000E+01" Y="9.069475000000E+02"/>
     <GCP Id="3" Pixel="0.0000" Line="765.0000" X="1.077140000000E+03" Y="7.841750000000E+01"/>
     <GCP Id="4" Pixel="380.0000" Line="765.0000" X="1.001970000000E+03" Y="1.080592500000E+03"/>
   </GCPList>
   <VRTRasterBand dataType="Byte" band="1">
     <ColorInterp>Gray</ColorInterp>
     <SimpleSource>
       <SourceFilename>tp_image2.tif</SourceFilename>
       <SourceBand>1</SourceBand>
       <SrcRect xOff="0" yOff="0" xSize="380" ySize="765"/>
       <DstRect xOff="0" yOff="0" xSize="380" ySize="765"/>
     </SimpleSource>
   </VRTRasterBand>
</VRTDataset>

You can use the gdal_translate -of VRT wrk.jpg wrk.vrt to create a .vrt file
referring tot he a given .jpg file, then "edit in" the <GCPList> element and
children either by hand with a text editor or with some sort of script.
Then you can use the .vrt file as the input to gdalwarp (or gdalwarptest).

I hope this helps.  As was suggested previously you can also, in theory, set
GCPs on an existing image using the SetGCPs() API entry point, but very few
formats support doing that on an existing file.  Perhaps VRT format is one
of the few that would support that.

If there is sufficient interest, I might write an addgcp.py script that would
add GCPs to an image (by creating a virtual image) from the commandline.

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