[gdal-dev] Warp a file from two separate Lat and Long

Andrew Brooks arb at sat.dundee.ac.uk
Thu Feb 18 12:42:08 EST 2010


On Thu, 18 Feb 2010 16:49:36 -0000, Luisa Peña <luisapena1979 at gmail.com> wrote:
>
> I've used GDAL a few times but this is the first time that I'm lost on what
> I can do with GDAL to solve my problem. I have 3 separate files, one with my
> data, other with Lattitude and another with Longitude. They have the same
> size and, as an example,  it means that Pixel (1,1) of data is located in
> latitude retrieved from Pixel (1,1) from latitude and longitude (pixel (1,1)
> from longitude). All of them are in WGS84 but without GCP's points.
> I need to create a georreferenced/rectified Geotiff with this data and, to
> do that, I need lat and Long. How can I do this?

In the past it has been suggested to use VRT files for this (don't know if
that's still the best solution?).

Create one VRT file which describes the Latitude file
Create one VRT file which describes the Longitude file
Create one VRT file which describes the data and references the
lat and lon VRT files as GEOLOCATION metadata.

The latter VRT file is the one you reference as the source image to a
gdalwarp/translate command.  It's all actually quite simple (see examples
below) but if you need some more specific advice then let me know.

Andrew


Example VRT file for latitude:

<VRTDataset rasterXSize="2048" rasterYSize="964">
   <SRS>GEOGCS[&quot;WGS 72&quot;,DATUM[&quot;WGS_1972&quot;,SPHEROID[&quot;WGS 7
2&quot;,6378135,298.26,AUTHORITY[&quot;EPSG&quot;,&quot;7043&quot;]],AUTHORITY[&
quot;EPSG&quot;,&quot;6322&quot;]],PRIMEM[&quot;Greenwich&quot;,0,AUTHORITY[&quo
t;EPSG&quot;,&quot;8901&quot;]],UNIT[&quot;degree&quot;,0.01745329251994328,AUTH
ORITY[&quot;EPSG&quot;,&quot;9122&quot;]],AUTHORITY[&quot;EPSG&quot;,&quot;4322&
quot;]]</SRS>
   <VRTRasterBand dataType="Float32" band="1" subClass="VRTRawRasterBand">
         <SourceFilename relativetoVRT="1">data.lat</SourceFilename>
     <ByteOrder>LSB</ByteOrder>
   </VRTRasterBand>
</VRTDataset>

Example VRT file for data (just to show the geolocation metadata reference):

<VRTDataset rasterXSize="2048" rasterYSize="964">
   <Metadata domain="GEOLOCATION">
     <MDI key="X_DATASET">data.lon.vrt</MDI>
     <MDI key="X_BAND">1</MDI>
     <MDI key="Y_DATASET">data.lat.vrt</MDI>
     <MDI key="Y_BAND">1</MDI>
     <MDI key="PIXEL_OFFSET">0</MDI>
     <MDI key="LINE_OFFSET">0</MDI>
     <MDI key="PIXEL_STEP">1</MDI>
     <MDI key="LINE_STEP">1</MDI>
   </Metadata>
   <SRS> stuff goes here</SRS>

   <VRTRasterBand dataType="UInt16" band="1" subClass="VRTRawRasterBand">
     <ImageOffset>1500</ImageOffset>
     <PixelOffset>10</PixelOffset>
     <LineOffset>22180</LineOffset>
     <ByteOrder>LSB</ByteOrder>
   </VRTRasterBand>
</VRTDataset>



More information about the gdal-dev mailing list