[Gdal-dev] projected bounding box

Ed McNierney ed at topozone.com
Mon Jul 14 12:39:19 EDT 2003


Jonathan -

This is a tricky problem to solve in a general case, and has been the source of a number of software bugs I've met along the way!

To do it right, you need to take EACH POINT along each of the edges of the output bounding box (rectangle) and reproject it back into the source projection.  For each edge you calculate the appropriate minimum/maximum value in the input projection.

You can probably get away with using fewer points (resampling along the line), but it might be easier for you to take your specific application and calculate a "buffer" value.  You can then do something like calculate the four corner points and use the buffer value to expand them so you choose an input area that's less than the whole file but big enough for your purposes.  This is obviously a special-case solution, but it's probably a lot simpler and faster than trying to solve the general problem.

	- Ed

Ed McNierney
President and Chief Mapmaker
TopoZone.com / Maps a la carte, Inc.
73 Princeton Street, Suite 305
North Chelmsford, MA  01863
ed at topozone.com
(978) 251-4242 

-----Original Message-----
From: Jonathan Coles [mailto:jonathan at intevation.de]
Sent: Monday, July 14, 2003 12:20 PM
To: gdal-dev at remotesensing.org
Subject: [Gdal-dev] projected bounding box


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.

Thanks.

--jonathan

-- 
======================================================================
 Jonathan Coles                                jonathan at intevation.de
 Intevation GmbH                             http://www.intevation.de
======================================================================




More information about the Gdal-dev mailing list