[Gdal-dev] Looking for some guidance...

Frank Warmerdam warmerdam at pobox.com
Thu Mar 4 10:12:30 EST 2004


Sandy Pyke wrote:
> Hello all,
> 
> I am working on a project where I have multiple large raster maps as my
> data source. The output of the project is to be a map scaled to a
> certain size covering a certain area. The output map may need data from
> 1 to 4 of the larger maps to generate the output map.
> 
> So far I have worked around converting my raster maps to GeoTIFF with
> the proper georeferencing applied, loading bounding boxes for these maps
> as well as the file names into a PostGIS database, calculating the
> desired map coverage, and extracting the relevant file names of the
> required output maps from the PostGIS database. I now know which files I
> need for my source data, I need to create the output map.
> 
> These output maps will be 1280 x 1024 x 8 maps and use a GCS of WGS84.
> 
> I have been able to get this to work on the command line using the
> following commands:
> 
> gdalwarptest -te -73.61837 45.38504 -73.32745 45.54867 \
>              -tr 1280 1024 inputfile1.tif outputfile.tif
> 
> gdalwarptest -srcnodata 0 inputfile2.tif outputfile.tif
> gdalwarptest -srcnodata 0 inputfile3.tif outputfile.tif
> gdalwarptest -srcnodata 0 inputfile4.tif outputfile.tif
> 
> gdal_translate outputfile.tif compressedoutput.png
> 
> I essentially want to get the same result, but in C / C++ code.
> 
> Conceptually I want to do the following:
> 
> - Generate the output dataset in memory
> - Warp the source image(s) to the memory dataset
> - Translate the memory dataset to a compressed image file
> 
> The API tutorials do make mention of the ability to create "in-memory"
> datasets but no information is given on how to do this. Can anyone offer
> some insight on this? Specifically, what driver should I use?
> 
> Also, if anyone can offer some insight on how I would go about
> implementing my desired functionality I would appreciate it.

Sandy,

All the steps are reproducable in C++ code of course.  You might want to
scan the gdalwarptest to see how it does it.   I would note that if you
are using gdalwarptest still you are using an older GDAL.  Giving various
advances on the warping code, I would encourage you to update.  There is
a 1.2.0 beta available on the ftp site now.

Second, on the issues of doing the work in memory.  When you create your
"working" dataset, use the driver name "MEM" instead of "GTiff" and you should
be OK.  The warping will all occur to this in memory raster, and then you can
use the CreateCopy() method on the PNG driver to turn this into a PNG file
when you are done.

I suppose I ought to document the MEM driver.  I haven't been so keen on it in
the past in part because I think it will be confusing to "normal" users.

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