[gdal-dev] Can't find a way of properly warping into a buffer

Brian Case rush at winkey.org
Mon Sep 12 14:44:30 EDT 2011


Daniele

a simple solution could be warp your image to an in memory raster
http://www.gdal.org/frmt_mem.html

Brian


On Mon, 2011-09-12 at 19:24 +0200, Daniele Tessaro wrote:
> Hello everybody,
> I'm really sorry if this post will be very long, but I swear I've
> spent a lot of time (days!)
> in trying to exactly understand this, also reading the sourcecode, but
> I'm a little bit stuck!
> 
> In my application I need to read data from a srtm90 tif file
> of extension 5 lat * 5 lon put in a raster of 6000x6000
> pixels, 2 bytes per pixel. This data will then be used as a heightmap
> texture for terrain rendering.
> 
> I have no problems in reading data using RasterIO function, I can also
> keep 72mb of raster data in system memory performing only
> one IO operation (so that I don't have to mess with async operations) but:
> 
> 1. I can't keep a 72MB texture in video memory (but the whole terrain
> extension should be
> rendered if the viewer is high enough), so I have to read a resampled
> lower resolution versions of the full terrain.
> (Actually more than one depending on the height of the viewpoint),
> and a full resolution version of a small piece of terrain that must be
> updated fast(only for small rectangular chunks)
> almost every time the user moves on the terrain.
> 
> 2. I'll map my terrain on a plane. This means that I need to transform
> data to some
> projected coordinate system. Suppose UTM, with the proper zone (I don't mind the
> deformations at the borders...).
> 
> Calling RasterIO in the proper way would solve problem 1, as it is
> exposing exactly the interface I need.
> The big issue is that it would be performing IO operations all the
> time, while I want to perform
> 1 single IO operation and then resample on that data.
> So first question: Is there a way of telling RasterIO to completely
> cache data and never access disk?
> 
> RasterIO would not solve problem 2, as I would get unprojected data as result,
> unless I get unprojected data and then I execute the projection.
> I don't think it's the correct approach, also because RasterIO only
> allows me only to read unprojected rectangular data,
> while I want to read projected rectangular data that would become
> trapezoidal if unprojected.
> 
> 
> I've also spent time with the Warping functions, but I can't figure
> out how to perform what I need.
> For what I've seen I should initialize a GDALWarpOperation with
> GDALWarpOptions so that:
> - hSrcDS is my source dataset
> - hDstDS is NULL, cause I want to warp to a buffer
> - pfnTransformer must be set so that it can map from pixel / line
> unprojected to pixel / line projected. I can use
>  GDALCreateGenImgProjTransformer but I have no destination dataset so
> I can't figure out how to set it up.
> 
> Then I can't exactly understand the WarpRegionToBuffer API.
> Suppose I need to sample in an output buffer of size W x H a region
> that in the projected coordinate system (so after the transform)
> is of size A x B. How should I set nDstXSize and nDstYSize? I would
> expect being able to specify both those couples of params because
> I should be able to get any region and to put it in any buffer
> performing the appropriate resampling. But that function is a little
> bit confusing
> me.
> 
> can anyone help me?:-)
> 
> thanks
> 
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev




More information about the gdal-dev mailing list