[Proj] Projecting a rectangle to another coord. system?

Frank Warmerdam warmerdam at pobox.com
Fri Sep 10 09:25:59 EDT 2004

Mikael Rittri wrote:
> Hello, 
> I am new to this list. 
> My problem is:
> - I have a rectangle given in coordinate system A
>   (defined by its southwest and northeast corners).  
> - In coordinate system B, I need to find one, or possibly
>   two, rectangles that cover all of the original rectangle.
>   The new rectangle(s) don't have to be as small as possible,
>   although this would be nice.  (They shouldn't be much too 
>   large, though.)
> (By a "coordinate system", I mean a geodetic datum plus a projection.)  
> Can proj4 (or some other tool) solve this problem in the general case?


Glynn and Ed's answers are right on the mark.  In case it is of any use,
I offer the msProjectRect() function from MapServer as a relatively
simple example using PROJ.4.  It converts points along the edge of the
rect at some preset density.  And if any edge points fail to convert it also
samples through the body of the rectangle in an effort to capture some
region of validity.

As Glynn mentions, an adaptive approach refining the resolution in areas
near the border would be much better but also somewhat harder to implement.

The MapServer solution is in the mapproject.c file (search for msProjectRect()).


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 Proj mailing list