[Gdal-dev] projected bounding box
Frank Warmerdam
warmerdam at pobox.com
Mon Jul 14 14:29:36 EDT 2003
Jonathan Coles wrote:
> hi,
>
> I'm using gdal to project a geotiff image to be displayed underneath
> vector map data. The extents that I use for the warping are the
> projected coordinates of the window corners. Sometimes the image only
> represents a small portion of the overall map and so the resulting image
> that is generated contains lots of essentially useless data, but it can
> take a very long time to render. To fix this problem I would like to
> only render that portion of the image that is truly important by setting
> the extents to the projected bounding box of the image's bounding box.
> My problem is now this: how do I calculate an accurate projected
> bounding box? I've found that simply projecting the corner coordinates
> is not enough because sometimes the maximum extents are beyond the
> corners, resulting in clipped images.
>
> I was hoping that GDAL/PROJ would have a function for this, but I
> couldn't find one. Any help will be much appreciated.
Jonathan,
As Ed mentions this is hard to do completely correctly. The
GDALSuggestedWarpOutput() is where I have it implemented for the image
warper applications. This code basically samples 20 points along each edge
to transform and compute a bounding box. This generally gives good results,
but objects it can be off a bit or even alot in degenerate situations.
You might want to glance at gdal/alg/gdaltransformer.cpp::GDALSuggsestedWarpOutput().
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